home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Freeware / FWCalendar / FWCAddEvent.rexx next >
Encoding:
OS/2 REXX Batch file  |  2002-03-13  |  117.4 KB  |  3,330 lines

  1. /*
  2.     AddEvent.rexx Macro
  3.     Adds events to calendars created by FWCalendar.rexx
  4.     $VER: FWCAddEvent.rexx v4.06 (21 Feb 2002)
  5.     ©Ron Goertz (goertz@earthlink.net)
  6. */
  7. MinFWCVer = 4.22
  8. OPTIONS RESULTS
  9. signal on syntax
  10. options failat 11
  11. Numeric Digits 14
  12.  
  13. parse source . . . FullCallPath . CallHost
  14. CallHost = strip(CallHost)
  15. ScriptDir = PathPart(FullCallPath)
  16.  
  17. CurrentDir = Pragma('D')
  18. if right(CurrentDir, 1) ~= ':' then CurrentDir = CurrentDir'/'
  19.  
  20. call AddLibraries
  21. if ErrorCount > 0 then call Cleanup
  22.  
  23. address value DetermineHost()
  24. call SetVariables
  25.  
  26. Month = substr(TempDate,5,2) - 0
  27. PrevMonth = Month - 1
  28. if PrevMonth = 0 then PrevMonth = 12
  29. NextMonth = Month + 1
  30. if NextMonth = 13 then NextMonth = 1
  31.  
  32. Year = left(TempDate,4)
  33. if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2  = 29
  34.  
  35. interpret "StartDate = Day."Date('W', TempDate, 'S')
  36. InternalStartMonth = DateInfo('I', TempDate, 'S')
  37. InternalEndMonth = DateInfo('I', left(TempDate, 6)''MonthLength.Month, 'S')
  38. if (DoExtended == 0) | (StartDate + MonthLength.Month > 35) then MaxDate = MonthLength.Month
  39. else MaxDate = 35 - StartDate
  40.  
  41. FontName = Font.Highlight
  42. FontSize = round(FSize.Highlight, 4)
  43. if ClassAct == 1 then call GetEvent_CA
  44. else call GetEvent_BGUI
  45. exit
  46.  
  47. /*********************************************/
  48. /*              Subroutines                  */
  49. /*********************************************/
  50. /***//*** AddBGUI (AB) ***/
  51. AddBGUI:
  52.   i = 0; AL_RexxBGUILib = i; AL_Lib.i = 'rexxbgui.library';    AL_MinVersion.i = 4;     AL_Offset.i = -30;  AL_Variable.i = 'RexxBGUILib'; AL_Status.i = "E"
  53.   i = 1; AL_BGUILib = i;     AL_Lib.i = 'bgui.library';        AL_MinVersion.i = 41.1;  AL_Offset.i = '' ;  AL_Variable.i = 'BGUILib';     AL_Status.i = "E"
  54.  
  55.   do i = 0 to 1
  56.     if exists('LIBS:'AL_lib.i) then do
  57.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  58.       AL_LibCount = AL_LibCount + 1
  59.       Library.Name.AL_LibCount = AL_Lib.i
  60.       Library.Version.AL_LibCount = AL_InstalledVersion
  61.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  62.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  63.         interpret Al_Variable.i' = 0'
  64.       end
  65.       else do
  66.         if i ~= AL_BGUILib then call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  67.         interpret Al_Variable.i' = 1'
  68.       end
  69.     end
  70.     else do
  71.       interpret Al_Variable.i' = 0'
  72.       if (i = AL_RexxBGUILib) | (i = AL_BGUILib) then do
  73.         if GUIWarning == 0 then do
  74.           GUIWarning = 1
  75.           call AddMsg('E', 'Either the ClassAct files or the BGUI files (see the docs)')
  76.           call AddMsg('E', '  must be installed. Neither could be found...')
  77.         end
  78.       end
  79.       else if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  80.     end
  81.   end
  82.   if RexxBGUILib == 1 then ClassAct = 0
  83.  
  84.   if (ClassAct == 0) & (bguiopen = 0) then bguiopen = bguiopen()
  85.  
  86.   return
  87. /**/
  88.  
  89. /***//*** AddLibraries (AL) ***/
  90. AddLibraries:
  91.   AL_LibCount     = 0
  92.   DoingCleanup    = 0
  93.   PortList        = show('P')
  94.   ErrorCount      = 0
  95.   HostScreen      = ''
  96.   WarningCount    = 0
  97.   Req             = 0
  98.   bguiopen        = 0
  99.   Storage         = 'RAM:FWC/'
  100.   ClassAct        = 0
  101.   ForceBGUI       = 0
  102.   ReqCAVersion    = 44.569
  103.   ReqAPVersion    = 2.48
  104.   ReqCAVersion    = 42.8
  105.   ClassActMessage = ''
  106.   AWNPipeMessage  = ''
  107.   GUIWarning      = 0
  108.  
  109.   call TranslationStrings
  110.   interpret ReadFile(ScriptDir'FWCTranslations.txt')
  111.  
  112.   i = 0; AL_DateLib = i;     AL_Lib.i = 'date.library';        AL_MinVersion.i = 33.31; AL_Offset.i = -492; AL_Variable.i = 'DateLib';     AL_Status.i = "W"
  113.   i = 1; AL_RexxMathLib = i; AL_Lib.i = 'rexxmathlib.library'; AL_MinVersion.i = 38.01;  AL_Offset.i = -30;  AL_Variable.i = 'RexxMathLib'; AL_Status.i = "W"
  114.  
  115.   if (exists('L:awnpipe-handler')) then do
  116.     if (exists('LIBS:gadgets/layout.gadget')) then do
  117.     ClassActVersion = PgmVer('LIBS:gadgets/layout.gadget')
  118.     AWNPipeVersion  = PgmVer('L:awnpipe-handler')
  119.     if ClassActVersion < ReqCAVersion then do
  120.       ClassActMessage = 'ClassAct version 'ReqCAVersion'+ is required; your version is 'ClassActVersion'. BGUI is being used'
  121.       ForceBGUI = 1
  122.     end
  123.     if AWNPipeVersion < ReqAPVersion then do
  124.       AWNPipeMessage = 'AWNPipe version 'ReqAPVersion'+ is required; your version is 'AWNPipeVersion'. BGUI is being used'
  125.       ForceBGUI = 1
  126.     end
  127.     if ForceBGUI == 0 then ClassAct = 1
  128.   end
  129.   if ForceBGUI == 1 then ClassAct = 0
  130.  
  131.   do i = 0 to 1
  132.     if exists('LIBS:'AL_lib.i) then do
  133.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  134.       AL_LibCount = AL_LibCount + 1
  135.       Library.Name.AL_LibCount = AL_Lib.i
  136.       Library.Version.AL_LibCount = AL_InstalledVersion
  137.       if (i == AL_RexxMathLib) & (AL_InstalledVersion == '38.02') then AL_InstalledVersion = 38.2
  138.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  139.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  140.         interpret Al_Variable.i' = 0'
  141.       end
  142.       else do
  143.         call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  144.         interpret Al_Variable.i' = 1'
  145.       end
  146.     end
  147.     else do
  148.       interpret Al_Variable.i' = 0'
  149.       if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  150.     end
  151.   end
  152.   if (DateLib == 1) | (RexxMathLib == 1) then PhaseLib = 1
  153.   else PhaseLib = 0
  154.  
  155.   if ForceBGUI == 1 then call AddBGUI
  156.  
  157.   if ErrorCount > 0 then call Cleanup
  158.   return
  159. /**/
  160.  
  161. /***//*** AddMsg (AM) Subroutine ***/
  162. AddMsg:
  163.   parse arg AM_MsgType, AM_Msg
  164.  
  165.   if AM_MsgType == 'E' then do
  166.     ErrorCount = ErrorCount + 1
  167.     Error.ErrorCount = AM_Msg
  168.   end
  169.   else do
  170.     WarningCount = WarningCount + 1
  171.     Warning.WarningCount = AM_Msg
  172.   end
  173.  
  174.   return
  175. /**/
  176.  
  177. /***//*** AssignID (AID) ***/
  178. AssignID:
  179.   parse arg AID_Var, AID_ID
  180.  
  181.   interpret AID_Var' = 'AID_ID
  182.   GE_Gad.AID_ID = AID_Var
  183.   if left(AID_Var, 5) = 'GadID' then AID_Var = 'GadID'
  184.   GE_Help.AID_ID = AID_Var'Help'
  185.  
  186.   return
  187. /**/
  188.  
  189. /***//*** BusyReq (BR) ***/
  190. /*** OpenBusy ***/
  191. OpenBusy:
  192.   parse arg BR_BusyTitle, BR_EventCount
  193.   BR_Progress = 0
  194.   if ClassAct == 1 then do
  195.     call open('ProgReq', "awnpipe:ProgressReq/xc")
  196.     call ToPIPE('ProgReq', 'm v cs si so a ps="'AppScreen'"')
  197.     call ToPIPE('ProgReq', 'label gt="'BR_BusyTitle', 'PleaseWait$'..."')
  198.     BR_ProgressGad = ToPIPE('ProgReq', 'fuelgauge defn=0 maxn='BR_EventCount' t=0 per')
  199.     call ToPIPE('ProgReq', 'layout b=0 si so cj')
  200.       call ToPIPE('ProgReq', 'space')
  201.       BR_CancelGad = ToPIPE('ProgReq', 'button pb gt="'Cancel$'"')
  202.       call ToPIPE('ProgReq', 'space')
  203.     call ToPIPE('ProgReq', 'le')
  204.     if ToPIPE('ProgReq', 'open') == 'window' then BR_ProgressWindow = 1
  205.     else BR_ProgressWindow = 0
  206.   end
  207.   else do
  208.     BR_ProgressGroup=bguivgroup(,
  209.           bguiinfo('BR_dummy',,'1B'x||'c'BR_BusyTitle', 'PleaseWait$'...')bguilayout(LGO_FixMinHeight,1)||,
  210.           bguiprogress('BR_prog2_',,0,BR_EventCount)||,
  211.           bguihgroup(,
  212.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1)||,
  213.                   bguibutton('BR_cancel_',Cancel$)bguilayout(LGO_FixMinHeight,1)||,
  214.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1),
  215.           ,,,,'W'),
  216.     ,-2,-2)
  217.     BR_ProgressWindow = bguiwindow('',BR_ProgressGroup,,2,,AppScreen)
  218.     if bguiwinopen(BR_ProgressWindow) = 0 then call Cleanup
  219.   end
  220.  
  221.   return BR_ProgressWindow
  222.  
  223. /*** UpdateBusy ***/
  224. UpdateBusy:
  225.   parse arg BR_ReqWin, BR_ProgressMade
  226.  
  227.   if BR_ReqWin == 0 then return 0
  228.   BR_Progress = BR_Progress + BR_ProgressMade
  229. /* say '>'BR_Progress SIGL */
  230.   if ClassAct == 1 then do
  231.     if show('F', 'ProgReq') == 1 then do
  232.       call writeln('ProgReq', 'id 'BR_CancelGad' read')
  233.       BR_CancelStatus = readln('ProgReq')
  234.       if BR_CancelStatus == 1 then do
  235.         call close('ProgReq')
  236.         return -1
  237.       end
  238.     end
  239.     else return 0
  240.     if show('F', 'ProgReq') == 1 then do
  241.       call ToPIPE('ProgReq', 'id 0 s=2')
  242.       call writeln('ProgReq', 'id 'BR_ProgressGad' defn='BR_Progress' ref')
  243.       call readln('ProgReq')
  244.     end
  245.     else return 0
  246.   end
  247.   else do
  248.     call bguiset(obj.BR_prog2_,BR_ReqWin,PROGRESS_Done,BR_Progress)
  249.     if bguiwinevent(BR_ReqWin,'ID') == id.BR_cancel_ then return -1
  250.   end
  251.  
  252.   return BR_Progress
  253.  
  254. /*** CloseBusy ***/
  255. CloseBusy:
  256.   parse arg BR_ReqWin
  257.  
  258.   if BR_ReqWin == 0 then return 0
  259.  
  260.   if ClassAct == 1 then call close('ProgReq')
  261.   else call bguiwinclose(BR_ReqWin)
  262.   Req = 0
  263.  
  264.   return 0
  265. /**/
  266.  
  267. /***//*** CAGetFile (GF) ***/
  268. CAGetFile:
  269.   parse arg GF_FileHandle, GF_GadID, GF_Title, GF_InitDir
  270.  
  271.   call writeln(GF_FileHandle,'id 'GF_GadID' gt="'GF_Title':" fn="'GF_InitDir'" s=1')
  272.   GF_GetFileResult = readln(GF_FileHandle)
  273.   parse var GF_GetFileResult GF_OK GF_Choice GF_File
  274.   if GF_Choice ~= 0 then GF_File = strip(GF_File, 'B', '" ')
  275.   else GF_File = ''
  276.  
  277.   return GF_File
  278. /**/
  279.  
  280. /***//*** CASimpleReq (CAS) ***/
  281. CASimpleReq:
  282.   parse arg CAS_Title, CAS_Msg, CAS_Time
  283.  
  284.   if CAS_Time == '' then do
  285.     CAS_Msg = translate(CAS_Msg, "'", '"')
  286.     do while pos('0a'x, CAS_Msg) > 0
  287.       CAS_Msg = left(CAS_Msg, pos('0a'x, CAS_Msg) - 1)'*n'substr(CAS_Msg, pos('0a'x, CAS_Msg) + 1)
  288.     end
  289.     call open('Req', "awnpipe:SimpleReq/xc")
  290.     call ToPIPE('Req', '"'CAS_Title'" m v db dg si so a ps="'AppScreen'"')
  291.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  292.     call ToPIPE('Req', 'layout b=0 si so cj')
  293.       call ToPIPE('Req', 'space')
  294.       call AssignID('CAS_OKGad', ToPIPE('Req', 'button c gt="'OK$'"'))
  295.       call AssignID('CAS_ViewGad', ToPIPE('Req', 'button c gt="'View$'"'))
  296.       call ToPIPE('Req', 'space')
  297.     call ToPIPE('Req', 'le')
  298.     call ToPIPE('Req', 'open')
  299.  
  300.     do until eof('Req')
  301.       call ToPIPE('Req', 'continue')
  302.       CAS_EventInfo = readln('Req')
  303.       parse var CAS_EventInfo CAS_Event' 'CAS_GadID' 'CAS_GadInfo1
  304.       if CAS_GadID == CAS_ViewGad then ViewLog = 1
  305.     end
  306.     call close('Req')
  307.   end
  308.   else do
  309.     call open('Req', "awnpipe:SimpleReq/xc")
  310.     call ToPIPE('Req', 'm sk si so a ps="'AppScreen'"')
  311.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  312.     call ToPIPE('Req', 'open')
  313.  
  314.     CAS_TickCount = 0
  315.     do until CAS_TickCount >= CAS_Time
  316.       call ToPIPE('Req', 'tick 100')
  317.       Req_EventInfo = readln('Req')
  318.       parse var Req_EventInfo Req_Event' 'Req_GadID' 'Req_GadInfo1
  319.       select
  320.         when Req_Event == 'key' then CAS_TickCount = CAS_Time
  321.         when Req_Event = 'tick' then CAS_TickCount = CAS_TickCount + 1
  322.         otherwise nop
  323.       end
  324.     end
  325.     call close('Req')
  326.   end
  327.  
  328.   return
  329. /**/
  330.  
  331. /***//*** Cleanup () Subroutine ***/
  332. Cleanup:
  333.   signal off syntax
  334.  
  335.   if VariablesSet == 1 then do
  336.     interpret UserPrefs
  337.     call CloseBusy(Req)
  338.     if App == 'FW' then do
  339.       SELECTOBJECT
  340.       REDRAW
  341.       if upper(DecimalFormat) == 'COMMA' then DocItemPrefs Decimal Comma
  342.     end
  343.     else if App == 'PGS' then do
  344.       SELECTOBJECT None WINDOW winName
  345.       if WindowRefreshed ~= 1 then do
  346.         REFRESH ON
  347.         REFRESHWINDOW WINDOW winName
  348.       end
  349.     end
  350.   end
  351.  
  352.   LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  353.   if LogOpen == 0 then do
  354.     address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  355.     LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  356.   end
  357.   if LogOpen == 1 then OutType = 'File'
  358.   if ((WarningCount > 0) | (ErrorCount > 0)) & (LogOpen == 0) then do
  359.     LogOpen = 1
  360.     call open('FWCLog', 'CON:10/10/500/300/FWCalendar.rexx Message/WAIT/CLOSE')
  361.     OutType = 'CON'
  362.   end
  363.  
  364.   if LogOpen == 1 then do
  365.     call writeln('FWCLog', '      Macro: 'strip(substr(sourceline(4), pos(':', sourceline(4)) + 1)))
  366.     call writeln('FWCLog', 'Application: 'PgmVersion)
  367.     call writeln('FWCLog', 'Current Dir: 'CurrentDir)
  368.     call writeln('FWCLog', ' Script Dir: 'ScriptDir)
  369.     call writeln('FWCLog', '       Host: 'CallHost)
  370.     call writeln('FWCLog', '   Calendar: 'Month.Month' 'Year||'0a'x)
  371.   end
  372.  
  373.   if (ErrorCount > 0) | (WarningCount > 0) then do
  374.     do i = 1 to ErrorCount
  375.       call writeln('FWCLog', Error.i)
  376.     end
  377.  
  378.     do i = 1 to WarningCount
  379.       call writeln('FWCLog', Warning.i)
  380.     end
  381.  
  382.     if (PrefsFile ~= '') & (exists(PrefsFile)) then do
  383.       call writeln('FWCLog', '0a'x||' -- 'PrefsFile' -- ')
  384.       call open('DataFile', PrefsFile)
  385.         do until eof('DataFile')
  386.           Ln = ReadLn('DataFile')
  387.           if pos('End Pass One', Ln) > 0 then leave
  388.           call writeln('FWCLog', Ln)
  389.         end
  390.       call close('DataFile')
  391.     end
  392.  
  393.     if (EventFile ~= '') & (symbol('EventFile') == 'VAR') then do
  394.       call writeln('FWCLog', '0a'x||' -- 'EventFile' -- ')
  395.       call open('DataFile', EventFile)
  396.         do while ~eof('DataFile')
  397.           if ~eof('DataFile') then call writeln('FWCLog', ReadLn('DataFile'))
  398.         end
  399.       call close('DataFile')
  400.     end
  401.  
  402.     if ErrorCount > 0 then ErrorType = Critical$
  403.     else ErrorType = Noncritical$
  404.     FileMsg = ErrorType' ... 'See$' 'Storage'FWCLog.txt 'ForDetails$'.'||'0a'x||ForwardLog$': Ron Goertz <rgoertz@midmaine.com>'||'0a'x||Unable$
  405.     Conbgui = ErrorType' ... 'SeeShell$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <rgoertz@midmaine.com>'||'0a'x||Unable$
  406.     ConCon  = ErrorType' ... 'SeeOutput$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <rgoertz@midmaine.com>'||'0a'x||Unable$
  407.  
  408.     if (OutType == 'File') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, FileMsg)
  409.     if (OutType == 'File') & (bguiopen == 1) then call bguireq('1B'x||'c'FileMsg,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  410.     if (OutType == 'File') & (bguiopen == 0) & (ClassAct == 0) then do
  411.       call open('CON', 'CON:10/10/500/300/FWCAddEvent notice/WAIT/CLOSE')
  412.         call writeln('CON', FileMsg)
  413.       call close('CON')
  414.     end
  415.  
  416.     if (OutType == 'CON') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, Conbgui)
  417.     if (OutType == 'CON') & (bguiopen == 1) then call bguireq('1B'x||'c'Conbgui,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  418.     if (OutType == 'CON') & (bguiopen == 0) & (ClassAct == 0) then call Writeln('FWCLog', '0a'x||ConCon)
  419.   end
  420.   else do
  421.     address command 'delete >NIL: 'Storage'FWC'App'Temp.txt quiet'
  422.     if LogOpen == 1 then call writeln('FWCLog', 'No errors.')
  423.   end
  424.  
  425.   address command 'delete >NIL: 'Storage'FWCTemp quiet'
  426.   call close('FWCLog')
  427.   if ViewLog == 1 then address command 'run MULTIVIEW 'Storage'FWCLog.txt'
  428.   if bguiopen = 1 then call bguiclose()
  429.   exit
  430. /**/
  431.  
  432. /***//*** ConvertDay (CD) Subroutine***/
  433. ConvertDay:
  434.   parse arg CD_Day
  435.   If upper(left(CD_Day,1)) == "P" then CD_Day = substr(CD_Day,2) - MonthLength.PrevMonth
  436.   If upper(left(CD_Day,1)) == "N" then CD_Day = substr(CD_Day,2) + MonthLength.Month
  437.   return CD_Day
  438. /**/
  439.  
  440. /***//*** DateInfo (PROCEDURE) ***/
  441. DateInfo: PROCEDURE
  442.   /* DateInfo('I', '19780101', 'S') = 2443510  */
  443.   /* Date('I', '19780101', 'S') = 0            */
  444.   /* Option 'C' returns days since Jan 1, xx00 */
  445.   parse arg Option, Date, Format
  446.  
  447.   if Option == '' then Option = 'N'
  448.   if Date == '' then do
  449.     Date = Date('S')
  450.     Format = 'S'
  451.   end
  452.  
  453.   Option = upper(left(Option, 1))
  454.   Format = upper(left(Format, 1))
  455.   if (Format == 'I') | (Format = '') then do
  456.     Format = 'I'
  457.  
  458.     /* Routine to convert from a serial date to year/month/day obtained from the        */
  459.     /* Sky & Telescope web site. The basic program from which the following was         */
  460.     /* derived originally appeared in Astronomical Computing, Sky & Telescope,May, 1984 */
  461.     A1 = trunc((Date / 36524.25) - 51.12264)
  462.     A = Date + 1 + A1 - trunc(A1 / 4)
  463.     B = A + 1524
  464.     C = trunc((B / 365.25) - 0.3343)
  465.     D = trunc(365.25 * C)
  466.     E = trunc((B - D) / 30.61)
  467.     D = B - D - trunc(30.61 * E)
  468.     Month = E - 1
  469.     Year = C - 4716
  470.     IF E > 13.5 then Month = Month - 12
  471.     IF Month < 2.5 then Year = Year + 1
  472.     Day = trunc(D)
  473.     J = Date
  474.   end
  475.   else do
  476.     Year  = left(Date, 4) - 0
  477.     Month = substr(Date, 5, 2) - 0
  478.     Day   = right(Date, 2) - 0
  479.     /* The following two lines are modified from PerpetualCalendar.bas that */
  480.     /* appeared in Astronomical Computing, Sky & Telescope, July, 1985      */
  481.     Temp = 0; if Month <= 2 then Temp = -1
  482.     J = 367*Year-trunc(7*(Year+trunc((Month + 9)/12))/4)+trunc(275*Month/9)+1721031-trunc(3*(trunc((Year+Temp)/100)+1)/4) + Day - 2
  483.   end
  484.  
  485.   select
  486.     when Option == 'B' then do
  487.       return J - 1721060
  488.     end
  489.     when Option == 'C' then do
  490.       return J + 2 - DateInfo('I', left(right(Year, 4, '0'), 2)'000101', 'S')
  491.     end
  492.     when (Option == 'D') | (Option == 'J') then do
  493.       DayCount = 0
  494.       MonthLength.1    = 31
  495.       MonthLength.2    = 28
  496.       MonthLength.3    = 31
  497.       MonthLength.4    = 30
  498.       MonthLength.5    = 31
  499.       MonthLength.6    = 30
  500.       MonthLength.7    = 31
  501.       MonthLength.8    = 31
  502.       MonthLength.9    = 30
  503.       MonthLength.10   = 31
  504.       MonthLength.11   = 30
  505.       MonthLength.12   = 31
  506.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  507.  
  508.       do I = (Month - 1) to 1 by -1
  509.         DayCount = DayCount + MonthLength.I
  510.       end
  511.       if Option == 'D' then return DayCount + Day
  512.       else return right(Year, 2)''right(DayCount + Day, 3, '0')
  513.     end
  514.     when Option == 'E' then do
  515.       return right(Day, 2, '0')'/'right(Month, 2, '0')'/'right(Year, 2, '0')
  516.     end
  517.     when Option == 'I' then return J
  518.     when (Option == 'M') | (Option == 'N') then do
  519.       Select
  520.         when Month ==  1 then Month = 'January'
  521.         when Month ==  2 then Month = 'February'
  522.         when Month ==  3 then Month = 'March'
  523.         when Month ==  4 then Month = 'April'
  524.         when Month ==  5 then Month = 'May'
  525.         when Month ==  6 then Month = 'June'
  526.         when Month ==  7 then Month = 'July'
  527.         when Month ==  8 then Month = 'August'
  528.         when Month ==  9 then Month = 'September'
  529.         when Month == 10 then Month = 'October'
  530.         when Month == 11 then Month = 'November'
  531.         when Month == 12 then Month = 'December'
  532.       end
  533.       if Option == 'M' then return Month
  534.       else return right(Day, 2, '0')' 'left(Month, 3)' 'Year
  535.     end
  536.     when Option == 'O' then return right(Year, 2, '0')'/'right(Month, 2, '0')'/'right(Day, 2, '0')
  537.     when Option == 'S' then return right(Year, 4, '0')''right(Month, 2, '0')''right(Day, 2, '0')
  538.     when Option == 'U' then return right(Month, 2, '0')'/'right(Day, 2, '0')'/'right(Year, 2, '0')
  539.     when Option == 'W' then do
  540.       J = J + 1
  541.       Weekday = J - 7 * trunc(J / 7)
  542.       Select
  543.         when Weekday == 0 then return 'Sunday'
  544.         when Weekday == 1 then return 'Monday'
  545.         when Weekday == 2 then return 'Tuesday'
  546.         when Weekday == 3 then return 'Wednesday'
  547.         when Weekday == 4 then return 'Thursday'
  548.         when Weekday == 5 then return 'Friday'
  549.         when Weekday == 6 then return 'Saturday'
  550.       end
  551.     end
  552.     otherwise return 0
  553.   end
  554. /**/
  555.  
  556. /***//*** DetermineHost () Subroutine ***/
  557. DetermineHost:
  558.   owner = ReadFile('ENV:Owner')
  559.   if (pos('FINALWRITER', upper(CurrentDir)) > 0) | (left(CallHost, 6) == 'FINALW') then do
  560.     App     = 'FW'
  561.     AppName = 'FINALWRITER'
  562.     if CallHost == 'REXX' then HostPort = substr(PortList, pos('FINALW.', PortList), 8)
  563.     else HostPort = CallHost
  564.     address value HostPort
  565.     GETDOCITEMPREFS Decimal; DecimalFormat = result
  566.     DOCITEMPREFS Decimal Period
  567.   end
  568.   else if (pos('PAGESTREAM', upper(CurrentDir)) > 0) | (CallHost == 'PAGESTREAM') then do
  569.     App     = 'PGS'
  570.     AppName = 'PAGESTREAM'
  571.     HostPort = 'PAGESTREAM'
  572.   end
  573.   else do
  574.     call AddMsg('E', 'Unable to determine host!')
  575.     call AddMsg('E', 'Make sure FWCAddEvent is called from Final Writer or PageStream')
  576.     call Cleanup
  577.   end
  578.  
  579.   PgmVersion = getclip('FWC'App'VersionInfo.txt')
  580.   if PgmVersion == '' then do
  581.     address command 'list >PIPE:FWC 'AppName'#? lformat %N'
  582.     ListOutput = ReadFile('PIPE:FWC')
  583.     call openv('ListOutput')
  584.       do while ~eofv('ListOutput')
  585.         PgmName = readvln('ListOutput')
  586.         if pos('.', PgmName) == 0 then leave
  587.       end
  588.     call closev('ListOutput')
  589.     address command 'version >PIPE:FWC 'PgmName
  590.     PgmVersion = ReadFile('PIPE:FWC')
  591.  
  592.     if left(PgmVersion, 34) == 'Could not find version information' then do
  593.       if App == 'FW' then do
  594.         call open('Temp', CurrentDir''PgmName)
  595.           /* Desired string at 325365 for v 5.06 */
  596.           /* Desired string at 333771 for FW97   */
  597.           FileOffset = 325300
  598.           call seek('Temp', FileOffset, 'B')
  599.           do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  600.             PrevOffset = FileOffset
  601.             Chunk = readch('Temp', 10000)
  602.             EndPos = pos('Created', Chunk)
  603.             if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  604.           end
  605.           if EndPos ~= 0 then do
  606.             StartPos = lastpos('Final', Chunk, EndPos)
  607.             EndPos = pos('00'x||'00'x, Chunk, StartPos)
  608.             PgmVersion = substr(Chunk, StartPos, EndPos - StartPos - 1)
  609.           end
  610.           else do
  611.             FileOffset = 0
  612.             call seek('Temp', FileOffset, 'B')
  613.             do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  614.               PrevOffset = FileOffset
  615.               Chunk = readch('Temp', 10000)
  616.               EndPos = pos('FinalWriter 97', Chunk)
  617.               if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  618.             end
  619.             if EndPos ~= 0 then PgmVersion = 'FinalWriter 97'
  620.             else PgmVersion = 'Final Writer - version unknown'
  621.           end
  622.         call close('Temp')
  623.       end
  624.       else if App == 'PGS' then do
  625.         PgmVersion = PgmName" - can't find version info"
  626.       end
  627.       call setclip('FWC'App'VersionInfo.txt', PgmVersion)
  628.     end
  629.   end
  630.  
  631.   AppScreen = ''
  632.   PubScreenApps = 'FrontPubScreen Publican MagicPubName'
  633.   do i = 1 to words(PubScreenApps)
  634.     interpret 'address command "'word(PubScreenApps, i)' >PIPE:FWC"'
  635.     if RC > 0 then iterate
  636.     AppScreen = readfile('PIPE:FWC')
  637.     if AppScreen ~= '' then leave
  638.   end
  639.  
  640.   return HostPort
  641. /**/
  642.  
  643. /***//*** DrawBox (DB) Subroutine ***/
  644. DrawBox:
  645.   parse arg DB_x1, DB_y1, DB_Width, DB_Height, DB_Weight, DB_Color, DB_FillBool, DB_FillColor, DB_Tint
  646.  
  647.   if DB_FillColor == '<'Clear$'>' then DB_FillBool = 0
  648.  
  649.   if App == 'FW' then do
  650.     if DB_Weight == 'HL' then DB_Weight = 'Hairline'
  651.     else if DB_Weight == 0 then do
  652.       DB_Weight = 'None'
  653.       if DB_FillColor ~= '<'Clear$'>' then DB_Color = DB_FillColor
  654.     end
  655.  
  656.     if DB_FillBool == 1 then DB_FillBool = 'Solid'
  657.     else do
  658.       DB_FillBool = 'Transparent'
  659.       DB_FillColor = DB_Color
  660.     end
  661.  
  662.     BOXPREFS LINEWT DB_Weight LINECOLOR '"'DB_Color'"' FILL DB_FillBool FILLCOLOR '"'DB_FillColor'"'
  663.     DRAWBOX 1 DB_x1 DB_y1 DB_Width DB_Height; DB_id = result
  664.   end
  665.   else if App == 'PGS' then do
  666.     if DB_Weight == 'HL' then DB_Weight = 0.3pt
  667.     else DB_Weight = DB_Weight'pt'
  668.  
  669.     if DB_FillBool == 1 then DB_FillBool = 'ON'
  670.     else DB_FillBool = 'OFF'
  671.  
  672.     If DB_Weight == 0 then DB_LineBool = 'OFF'
  673.     else DB_LineBool = 'ON'
  674.  
  675.     DRAWBOX DB_x1 DB_y1 DB_x1 + DB_Width DB_y1 + DB_Height WINDOW winName; DB_id = result
  676.     STROKED DB_LineBool OBJECTID DB_id WINDOW winName
  677.     SETSTROKEWEIGHT DB_Weight STROKENUMBER 0 OBJECTID DB_id WINDOW winName
  678.     SETCOLORSTYLE '"'DB_Color'"' COLORNUMBER 0 STROKENUMBER 0 OBJECTID DB_id WINDOW winName
  679.     FILLED DB_FillBool OBJECTID DB_id WINDOW winName
  680.     SETCOLORSTYLE '"'DB_FillColor'"' COLORNUMBER 0 FILL OBJECTID DB_id WINDOW winName
  681.     SETCOLORTINT DB_Tint FILL OBJECTID DB_id WINDOW winName
  682.   end
  683.   return DB_id
  684. /**/
  685.  
  686. /***//*** dTox (PROCEDURE) Subroutine ***/
  687. dTox:PROCEDURE
  688. parse arg DecVal
  689.  
  690. BinVal = ''
  691. HexVal = ''
  692. do i = 32 to 0 by -1
  693.   if DecVal >= 2**i then do
  694.     BinVal = BinVal'1'
  695.     DecVal = DecVal - 2**i
  696.   end
  697.   else BinVal = BinVal'0'
  698. end
  699.  
  700. do until BinVal == ''
  701.   HexVal = c2x(b2c(right(BinVal, 8, '0')))''HexVal
  702.   if length(BinVal) >= 8 then CutLength = 8
  703.   else CutLength = length(BinVal)
  704.   BinVal = left(BinVal, length(BinVal) - CutLength)
  705. end
  706.  
  707. return HexVal
  708. /**/
  709.  
  710. /***//*** GetEvent_BGUI (GE) Subroutine ***/
  711. GetEvent_BGUI:
  712.   do GE_i = 0 to 15
  713.     linelist_.GE_i = GE_i
  714.   end
  715.   linelist_.COUNT = min(RowsThatFit, 16)
  716.  
  717.   call bguilist("eventlist_",Event$,Image$,File$)
  718.   call bguilist("FrequencyList", Once$, Weekly$, Biweekly$)
  719.  
  720.   GE_StartOrEnd   = 1
  721.   GE_StartDate    = ""
  722.   GE_EndDate      = ""
  723.   GE_Boxed.0      = ""
  724.   GE_Boxed.128    = "B"
  725.   GE_Weekly.0     = ""
  726.   GE_Weekly.1     = "W"
  727.   GE_Weekly.2     = "2"
  728.   GadID.          = ''
  729.   GE_Arg.         = ''
  730.   GE_i            = 0
  731.   GE_Day          = 0
  732.   GE_PrevDay      = MonthLength.PrevMonth - StartDate
  733.   GE_NextDay      = 0
  734.  
  735.   Req = OpenBusy(PrepReq$, 45)
  736.   do while (GE_i < 6)
  737.     GE_j = 0
  738.     do while (GE_j < 7)
  739.       call UpdateBusy(Req, 1)
  740.       GE_SerialPosition = (GE_i * 7) + GE_j
  741.       GE_Button = GE_SerialPosition + 1
  742.       if (GE_SerialPosition >= StartDate) & (GE_SerialPosition < StartDate + MonthLength.Month) then Do
  743.         GE_Day = GE_Day + 1
  744.         interpret "GadID."GE_Button" = bguibutton('"GE_Button"_', GE_Day)"
  745.         GadID = GetID(GE_Button'_')
  746.         GE_Arg.GadID = 'C 'left(Month.Month, 3)' 'GE_Day
  747.       end
  748.       else do
  749.         if GE_SerialPosition < StartDate then Do
  750.           GE_PrevDay = GE_PrevDay + 1
  751.           interpret "GadID."GE_Button" = bguibutton('"GE_Button"_', GE_PrevDay)"
  752.           GadID = GetID(GE_Button'_')
  753.           GE_Arg.GadID = 'P 'left(Month.PrevMonth, 3)' 'GE_PrevDay
  754.         end
  755.         else do
  756.           GE_NextDay = GE_NextDay + 1
  757.           interpret "GadID."GE_Button" = bguibutton('"GE_Button"_', GE_NextDay)"
  758.           GadID = GetID(GE_Button'_')
  759.           GE_Arg.GadID = 'N 'left(Month.NextMonth, 3)' 'GE_NextDay
  760.         end
  761.       end
  762.       GE_j = GE_j + 1
  763.     end
  764.     GE_i = GE_i + 1
  765.     if GE_SerialPosition >= StartDate + MonthLength.Month - 1 then leave
  766.   end
  767.  
  768.   DateButtons = bguihgroup(GadID.1""GadID.2""GadID.3""GadID.4""GadID.5""GadID.6""GadID.7)||,
  769.                 bguihgroup(GadID.8""GadID.9""GadID.10""GadID.11""GadID.12""GadID.13""GadID.14)||,
  770.                 bguihgroup(GadID.15""GadID.16""GadID.17""GadID.18""GadID.19""GadID.20""GadID.21)||,
  771.                 bguihgroup(GadID.22""GadID.23""GadID.24""GadID.25""GadID.26""GadID.27""GadID.28)
  772.   if GE_i > 4 then DateButtons = DateButtons''bguihgroup(GadID.29""GadID.30""GadID.31""GadID.32""GadID.33""GadID.34""GadID.35)
  773.   if GE_i > 5 then DateButtons = DateButtons''bguihgroup(GadID.36""GadID.37""GadID.38""GadID.39""GadID.40""GadID.41""GadID.42)
  774.  
  775.   g=bguivgroup(,
  776.     bguihgroup(,
  777.       bguicycle("eventtype_",,"eventlist_")bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  778.       bguistring("event_",,,256)bguilayout(LGO_FixMinHeight,1)||,
  779.       bguiibutton('getfile_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1),
  780.     )||,
  781.     bguihgroup(,
  782.       bguistring('fontvalue_',Font$':',FontName,256)bguilayout(LGO_Weight,50,LGO_FixMinHeight,1)||,
  783.       bguistring('fontsize_',,FontSize,8)bguilayout(LGO_Weight,10,LGO_FixMinHeight,1)||,
  784.       bguiibutton('addfont_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  785.       bguibutton("reset_",Reset$)bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1),
  786.     )||,
  787.     bguihgroup(,
  788.       bguivgroup(,
  789.         bguiinfo('dummy_',,esc'c'Month.Month)bguilayout(LGO_FixMinHeight, 1)||,
  790.         bguihgroup(,
  791.           bguiinfo("dummy_",,esc"c"left(TransDay.0,1))||,
  792.           bguiinfo("dummy_",,esc"c"left(TransDay.1,1))||,
  793.           bguiinfo("dummy_",,esc"c"left(TransDay.2,1))||,
  794.           bguiinfo("dummy_",,esc"c"left(TransDay.3,1))||,
  795.           bguiinfo("dummy_",,esc"c"left(TransDay.4,1))||,
  796.           bguiinfo("dummy_",,esc"c"left(TransDay.5,1))||,
  797.           bguiinfo("dummy_",,esc"c"left(TransDay.6,1)),
  798.         )||,
  799.         DateButtons,
  800.       )||,
  801.       bguivgroup(,
  802.         bguiinfo("startchoice_",esc"r"Start$':',"")bguilayout(LGO_FixMinHeight, 1)||,
  803.         bguiinfo("endchoice_",esc"r"End$':',"")bguilayout(LGO_FixMinHeight, 1)||,
  804.         bguicycle('textcolor_',esc"r"TextColor$':','TextColorList')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  805.         bguicycle("linechoice_",esc"r"Line$':',"linelist_")bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  806.         bguicheckbox("boxchoice_",esc"r"Boxed$':',0)bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  807.         bguicycle('boxcolor_',esc"r"BoxColor$':','ColorList')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  808.         bguicycle("weeklychoice_",esc"r"Frequency$':','FrequencyList')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  809.         bguihgroup(,
  810.           bguibutton("OK_",OK$)bguilayout(LGO_FixMinHeight,1)||,
  811.           bguibutton("cancel_",Cancel$)bguilayout(LGO_FixMinHeight,1)||,
  812.           bguibutton("undo_",Undo$)bguilayout(LGO_FixMinHeight,1),
  813.         ),
  814.       ),
  815.     ),
  816.   ,"-1","-1")
  817.  
  818.   call UpdateBusy(Req, 1)
  819.   GE_winID=bguiwindow(EnterEventInfo$':',g,5,0,,AppScreen)
  820.   call UpdateBusy(Req, 1)
  821.  
  822.   if App == 'PGS' then do
  823.     FontGroup=bguivgroup(bguilistview('fontlistview_',,'FontList'))
  824.     call UpdateBusy(Req, 1)
  825.     FontwinID=bguiwindow(SelectFont$':',FontGroup,20,50,,AppScreen)
  826.   end
  827.  
  828.   call bguiset(obj.linechoice_,GE_winID,CYC_Active,1)
  829.   call bguiset(obj.boxcolor_,GE_winID,CYC_Active,max(0, MemberID(Background.AddEvent,'ColorList', ColorList.Count, 0)))
  830.   call bguiset(obj.textcolor_,GE_winID,CYC_Active,max(0, MemberID(Color.AddEvent,'ColorList', ColorList.Count, 0)))
  831.   call bguiset(obj.event_,,BT_Key,EventKey)
  832.   call bguiwintabcycleorder(GE_winID,obj.event_||obj.fontsize_)
  833.   call bguiset(obj.undo_, GE_winID, GA_Disabled, 1)
  834.  
  835.   if bguiwinopen(GE_winID)=0 then bguierror(12)
  836.  
  837.   call CloseBusy(Req)
  838.  
  839.   id=0
  840.   do while 1
  841.     call bguiwinwaitevent(GE_winID,"ID")
  842.     select
  843.       when (id == id.cancel_) | (id == id.winclose) then call Cleanup
  844.       when id == id.winactive then nop
  845.       when id == id.wininactive then nop
  846.       when id == id.event_ then nop
  847.       when id == id.linechoice_ then nop
  848.       when id == id.boxchoice_ then nop
  849.       when id == id.textcolor_ then nop
  850.       when id == id.boxcolor_ then nop
  851.       when id == id.weeklychoice_ then nop
  852.       when id == id.eventtype_ then do
  853.         GE_EventType = bguiget(obj.eventtype_, CYC_Active)
  854.         GE_StartOrEnd = 1
  855.         if Type.GE_EventType == Event$ then GE_DisableFlag = 0
  856.         else GE_DisableFlag = 1
  857.         call bguiset(obj.event_,GE_winID,STRINGA_TextVal,"")
  858.         call bguiset(obj.getfile_, GE_winID, GA_Disabled, 1-GE_DisableFlag)
  859.         call bguiset(obj.textcolor_, GE_winID, GA_Disabled, GE_DisableFlag)
  860.         call bguiset(obj.boxcolor_, GE_winID, GA_Disabled, GE_DisableFlag)
  861.         call bguiset(obj.linechoice_, GE_winID, GA_Disabled, GE_DisableFlag)
  862.         call bguiset(obj.boxchoice_, GE_winID, GA_Disabled, GE_DisableFlag)
  863.         call bguiset(obj.weeklychoice_, GE_winID, GA_Disabled, GE_DisableFlag)
  864.         call bguiset(obj.reset_, GE_winID, GA_Disabled, GE_DisableFlag)
  865.         call bguiset(obj.addfont_, GE_winID, GA_Disabled, GE_DisableFlag)
  866.         call bguiset(obj.fontsize_, GE_winID, GA_Disabled, GE_DisableFlag)
  867.         call bguiset(obj.fontvalue_, GE_winID, GA_Disabled, GE_DisableFlag)
  868.       end
  869.       when id == id.getfile_ then do
  870.         if Type.GE_EventType == Image$ then do
  871.           address command 'assign >NIL: FWC: 'ScriptDir'Images/'
  872.           if RC == 20 then GE_Dir = ScriptDir
  873.           else do
  874.             GE_Dir = ScriptDir'Images/'
  875.             address command 'assign >NIL: FWC:'
  876.           end
  877.           GE_DataFile = bguifilereq(GE_Dir, SelectImage$, GE_winID)
  878.         end
  879.         else do
  880.           GE_DataFile = bguifilereq(ScriptDir, SelectFile$, GE_winID,DOPATTERNS,PatVar)
  881.         end
  882.         if ~exists(GE_DataFile) then do
  883.           call bguireq(GE_DataFile' 'CantFind$'...','*'OK$,'FWCAddEvent 'Notice$,GE_winID)
  884.           GE_DataFile = ''
  885.         end
  886.         else call bguiset(obj.event_,GE_winID,STRINGA_TextVal,GE_DataFile)
  887.       end
  888.       when id == id.reset_ then do
  889.         FontName = Font.Highlight
  890.         FontSize = FSize.Highlight
  891.         call bguiset(obj.fontvalue_, GE_winID, STRINGA_TextVal,FontName)
  892.         call bguiset(obj.fontsize_, GE_winID, STRINGA_TextVal,FontSize)
  893.       end
  894.       when id == id.fontvalue_ then do
  895.         call bguireq('1b'x||"c"MustUse$,"*"OK$,'',GE_winID)
  896.         call bguiset(obj.fontvalue_, GE_winID,STRINGA_TextVal, FontName)
  897.       end
  898.       when id == id.fontsize_ then nop
  899.       when id == id.addfont_ then do
  900.         call bguiwinbusy(GE_winID)
  901.         if App == 'FW' then do
  902.           FontFile = bguifilereq(CurrentDir'FWFonts/SWOLFonts/', SelectFont$':', GE_winID,,'#?')
  903.           if FontFile ~= '' then call bguiset(obj.fontvalue_, GE_winID, STRINGA_TextVal,FontFile)
  904.         end
  905.         else if App == 'PGS' then do
  906.           call bguiwinopen(FontwinID)
  907.           do while 1
  908.             call bguiwinwaitevent(FontwinID,'ID')
  909.             if id == id.winclose then leave
  910.             if id == id.fontlistview_ then do
  911.               call bguiset(obj.fontvalue_, GE_winID, STRINGA_TextVal,bguiget(obj.fontlistview_, LISTV_LastClicked))
  912.               leave
  913.             end
  914.           end
  915.           call bguiwinclose(FontwinID)
  916.         end
  917.         call bguiwinready(GE_winID)
  918.         FontName = bguiget(obj.fontvalue_, STRINGA_TextVal)
  919.       end
  920.       when id == id.ok_ then do
  921.         GE_EventValue = bguiget(obj.event_, STRINGA_TextVal)
  922.         GE_BoxValue   = bguiget(obj.boxchoice_, GA_Selected)
  923.         GE_EventType  = bguiget(obj.eventtype_, CYC_Active)
  924.         if (GE_StartDate == "") & (Type.GE_EventType == Event$) then call bguireq(EnterStartDate$'...','*'OK$,'FWCAddEvent 'Notice$,GE_winID)
  925.         else if (GE_EventValue == "") & (GE_Boxed.GE_BoxValue == "") then call bguireq(EnterEvent$'...','*'OK$,'FWCAddEvent 'Notice$,GE_winID)
  926.         else do
  927.           GE_WeeklyValue  = bguiget(obj.weeklychoice_, CYC_Active)
  928.  
  929.           EventData = "   EventType = "Type.GE_EventType||'0a'x||,
  930.                       " EnteredFont = "strip(FontName)||'0a'x||,
  931.                       " EnteredSize = "strip(bguiget(obj.fontsize_, STRINGA_TextVal))||'0a'x||,
  932.                       " EnteredDay1 = "strip(GE_StartDate)||'0a'x||,
  933.                       " EnteredDay2 = "strip(GE_EndDate)||'0a'x||,
  934.                       " EnteredLine = "bguiget(obj.linechoice_, CYC_Active)||'0a'x||,
  935.                       "     Options = "GE_Boxed.GE_BoxValue""GE_Weekly.GE_WeeklyValue||'0a'x||,
  936.                       "   TextColor = "value('ColorList.'bguiget(obj.textcolor_, CYC_Active))||'0a'x||,
  937.                       "    BoxColor = "value('ColorList.'bguiget(obj.boxcolor_, CYC_Active))||'0a'x||,
  938.                       "EnteredEvent = "GE_EventValue
  939.  
  940.           call bguiwinclose(GE_winID)
  941.           call ProcessEvent
  942.           call bguiwinopen(GE_winID)
  943.  
  944.           if UndoLevel == 0 then UndoStatus = 1
  945.           else UndoStatus = 0
  946.           call bguiset(obj.undo_, GE_winID, GA_Disabled, UndoStatus)
  947.  
  948.           GE_StartOrEnd = 1
  949.           GE_StartDate  = ""
  950.           GE_EndDate    = ""
  951.           call bguiset(obj.startchoice_,GE_winID,INFO_TextFormat,'')
  952.           call bguiset(obj.endchoice_,GE_winID,INFO_TextFormat,'')
  953.         end
  954.       end
  955.       when id == id.undo_ then do
  956.         call bguiwinclose(GE_winID)
  957.           do GE_i = 1 to Undo.UndoLevel.0
  958.             if App == 'FW' then DELETEOBJECT Undo.UndoLevel.GE_i
  959.             else if App == 'PGS' then do
  960.               SELECTOBJECT OBJECTID Undo.UndoLevel.GE_i WINDOW winName
  961.               DELETEOBJECT OBJECTID Undo.UndoLevel.GE_i WINDOW winName
  962.             end
  963.           end
  964.           UndoLevel = UndoLevel - 1
  965.           if UndoLevel == 0 then UndoStatus = 1
  966.           else UndoStatus = 0
  967.           call bguiset(obj.undo_, GE_winID, GA_Disabled, UndoStatus)
  968.         call bguiwinopen(GE_winID)
  969.       end
  970.       otherwise do
  971.         GE_StartOrEnd = 1 - GE_StartOrEnd
  972.         GE_ReturnDate = strip(substr(GE_Arg.id, 1, 1)""right(GE_Arg.id, 2), "B", "C")
  973.         GE_Date = substr(GE_Arg.id, 3)
  974.         if GE_StartOrEnd == 0 then do
  975.           call bguiset(obj.startchoice_,GE_winID,INFO_TextFormat,esc"l"GE_Date)
  976.           GE_StartDate = GE_ReturnDate
  977.         end
  978.         else do
  979.           call bguiset(obj.endchoice_,GE_winID,INFO_TextFormat,esc"l"GE_Date)
  980.           GE_EndDate = GE_ReturnDate
  981.         end
  982.       end
  983.     end
  984.   end
  985.   exit
  986. /**/
  987.  
  988. /***//*** GetEvent_CA (GE) Subroutine ***/
  989. GetEvent_CA:
  990.   /***//*** Initialize Variables ***/
  991.   Req = OpenBusy(PrepReq$, 4 + (ColorList.Count - 1))
  992.  
  993.   GE_BoxValue     = ''
  994.   GE_EnteredLine  = 1
  995.   GE_EventType    = Event$
  996.   GE_EventValue   = ''
  997.   GE_StartOrEnd   = 1
  998.   GE_StartDate    = ""
  999.   GE_EndDate      = ""
  1000.   GE_WeeklyValue  = ''
  1001.   GE_Day          = 0
  1002.   GE_PrevDay      = MonthLength.PrevMonth - StartDate
  1003.   GE_NextDay      = 0
  1004.   GE_StoreEvent$  = ''
  1005.   GE_StoreImage$  = ''
  1006.   GE_StoreFile$   = ''
  1007.   LineList        = ''
  1008.   ColorList       = ''
  1009.   FontReq         = 0
  1010.   ColorReq        = 0
  1011.   NCColorReq      = 0
  1012.   interpret 'GE_TextColor = ColorList.'max(0, MemberID(Color.AddEvent,'ColorList', ColorList.Count, 0))
  1013.   interpret 'GE_BoxColor = ColorList.'max(0, MemberID(Background.AddEvent,'ColorList', ColorList.Count, 0))
  1014.  
  1015.   GadID.          = ''
  1016.   GadArg.         = ''
  1017.   GE_Boxed.0      = ""
  1018.   GE_Boxed.1      = "B"
  1019.   GE_Type.0       = Event$
  1020.   GE_Type.1       = Image$
  1021.   GE_Type.2       = File$
  1022.   GE_Weekly.0     = ""
  1023.   GE_Weekly.1     = "W"
  1024.   GE_Weekly.2     = "2"
  1025.  
  1026.   do GE_i = 0 to 15
  1027.     LineList = LineList''GE_i'|'
  1028.   end
  1029.   LineList.Count = min(RowsThatFit, 16)
  1030.  
  1031.   do GE_i = 0 to ColorList.Count - 1
  1032.     ColorList = ColorList''ColorList.GE_i'|'
  1033.   end
  1034.   ColorList = '"'strip(ColorList, 'B', '|')'"'
  1035.  
  1036.   EventList = '"'Event$'|'Image$'|'File$'"'
  1037.   FrequencyList = '"'Once$'|'Weekly$'|'Biweekly$'"'
  1038.  
  1039.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  1040. /**/
  1041.  
  1042.   /***//*** GUI Description ***/
  1043.   call open('GE',"awnpipe:AddEvent/xc")
  1044.   FWCAddEventVersion = '('strip(word(sourceline(4), 3))')'
  1045.  
  1046.   call ToPIPE('GE', '"'EnterEventInfo$' 'FWCAddEventVersion'" m cg dg v db a so si cs sk h ps="'AppScreen'"')
  1047.  
  1048.   call ToPIPE('GE', 'layout v so si b=0')
  1049.     call ToPIPE('GE', 'layout b=0')
  1050.       call AssignID('GE_EventTypeGad', ToPIPE('GE', 'chooser weiw=0 pu cl='EventList' ref'))
  1051.       call AssignID('GE_EventGad', ToPIPE('GE', 'string tc lj ref'))
  1052.       call AssignID('GE_ChooseFileGad', ToPIPE('GE', 'button ab=0 weiw=0 weih=0 dis=1 ref'))
  1053.     call ToPIPE('GE', 'le')
  1054.  
  1055.     call ToPIPE('GE', 'layout b=0')
  1056.       call ToPIPE('GE', 'label gt="'Font$':" ua ref')
  1057.       call AssignID('GE_FontNameGad', ToPIPE('GE', 'string lj tc chl weiw=95 gt="'FontName'" ref'))
  1058.       call AssignID('GE_FontSizeGad', ToPIPE('GE', 'string lj tc minc=6 weiw=0 gt="'FontSize'" ref'))
  1059.       call AssignID('GE_ChooseFontGad', ToPIPE('GE', 'button ab=2 weiw=0 weih=0 ref'))
  1060.       call AssignID('GE_ResetGad', ToPIPE('GE', 'button weih=0 weiw=0 gt="'Reset$'" ref'))
  1061.     call ToPIPE('GE', 'le')
  1062.   call ToPIPE('GE', 'le')
  1063.  
  1064.   call ToPIPE('GE', 'layout weiw=0 b=0')
  1065.     call ToPIPE('GE', 'layout weiw=0 so v')
  1066.       call ToPIPE('GE', 'layout so b=0')
  1067.         call ToPIPE('GE', 'space')
  1068.         call AssignID('GE_MonthGad', ToPIPE('GE', 'button ro b=0 gt="'Month.Month'" ref'))
  1069.         call ToPIPE('GE', 'space')
  1070.       call ToPIPE('GE', 'le')
  1071.  
  1072.       call ToPIPE('GE', 'layout e b=0')
  1073.         do i = 0 to WeekDayCount
  1074.           interpret "call ToPIPE('GE', 'button ro b=0 gt='QuoteMark''left(TransDay.i, 1)''QuoteMark' ref')"
  1075.         end
  1076.       call ToPIPE('GE', 'le')
  1077.  
  1078.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  1079.  
  1080.       do GE_Week = 0 to 5
  1081.         if GE_Week * 7 + WeekdayCount < StartDate then do
  1082.           GE_Day = 7 - StartDate
  1083.           iterate
  1084.         end
  1085.         call ToPIPE('GE', 'layout e b=0')
  1086.         do GE_WeekDay = 0 to 6
  1087.           GE_Posn = (GE_Week * 7) + GE_WeekDay
  1088.           if (GE_Posn >= StartDate) & (GE_Posn < StartDate + MonthLength.Month) then do
  1089.             GE_Day = GE_Day + 1
  1090.             if GE_WeekDay <= WeekdayCount then do
  1091.               call AssignID('GadID.'GE_Posn, ToPIPE('GE', 'button gt="'GE_Day'" ref'))
  1092.               interpret "GadArg."GadID.GE_Posn" = 'C'left(Month.Month, 3)' 'GE_Day"
  1093.             end
  1094.           end
  1095.           else do
  1096.             if GE_Posn < StartDate then do
  1097.               GE_PrevDay = GE_PrevDay + 1
  1098.               if GE_WeekDay <= WeekdayCount then do
  1099.                 call AssignID('GadID.'GE_Posn, ToPIPE('GE', 'button gt="'GE_PrevDay'" ref'))
  1100.                 interpret "GadArg."GadID.GE_Posn" = 'P'left(Month.PrevMonth, 3)' 'GE_PrevDay"
  1101.               end
  1102.             end
  1103.             else do
  1104.               GE_NextDay = GE_NextDay + 1
  1105.               if GE_WeekDay <= WeekdayCount then do
  1106.                 call AssignID('GadID.'GE_Posn, ToPIPE('GE', 'button gt="'GE_NextDay'" ref'))
  1107.                 interpret "GadArg."GadID.GE_Posn" = 'N'left(Month.NextMonth, 3)' 'GE_NextDay"
  1108.               end
  1109.             end
  1110.           end
  1111.         end
  1112.         call ToPIPE('GE', 'le')
  1113.         if GE_Posn >= StartDate + MonthLength.Month - 1 then leave
  1114.       end
  1115.     call ToPIPE('GE', 'le')
  1116.  
  1117.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  1118.     call ToPIPE('GE', 'layout weiw=0 si so v')
  1119.       call ToPIPE('GE', 'layout weiw=0 si so b=0 v')
  1120.         call ToPIPE('GE', 'label weiw=0 ua gt="'Start$':" ref')
  1121.         call AssignID('GE_StartGad', ToPIPE('GE', 'button lj chl ro b=0 ref'))
  1122.         call ToPIPE('GE', 'label weiw=0 ua gt="'End$':" ref')
  1123.         call AssignID('GE_EndGad', ToPIPE('GE', 'button lj chl ro b=0 ref'))
  1124.         call ToPIPE('GE', 'label weiw=0 gt="'TextColor$':" ua ref')
  1125.         call AssignID('GE_TextColorGad', ToPIPE('GE', 'Button chl gt="'Color.AddEvent'" ref'))
  1126.         call ToPIPE('GE', 'label weiw=0 gt="'Line$':" ua ref')
  1127.         call AssignID('GE_LineGad', ToPIPE('GE', 'chooser chl pu weiw=0 s=1 maxn='LineList.Count' cl='LineList' ref'))
  1128.         call ToPIPE('GE', 'label weiw=0 gt="'Boxed$':" ua ref')
  1129.         call AssignID('GE_BoxedGad', ToPIPE('GE', 'checkbox weiw=0 chl ref'))
  1130.         call ToPIPE('GE', 'label weiw=0 gt="'BoxColor$':" ua ref')
  1131.         call AssignID('GE_BoxColorGad', ToPIPE('GE', 'Button chl gt="'Background.AddEvent'" ref'))
  1132.         call ToPIPE('GE', 'label weiw=0 gt="'Frequency$':" ua ref')
  1133.         call AssignID('GE_FrequencyGad', ToPIPE('GE', 'chooser chl pu weiw=0 maxn=3 cl='FrequencyList' ref'))
  1134.       call ToPIPE('GE', 'le')
  1135.       call ToPIPE('GE', 'layout v si e cj b=0')
  1136.         call ToPIPE('GE', 'layout si e weiw=0 b=0')
  1137.           call AssignID('GE_OKGad', ToPIPE('GE', 'button weiw=0 weih=0 gt="'OK$'" ref'))
  1138.           call AssignID('GE_CancelGad', ToPIPE('GE', 'button weiw=0 weih=0 c gt="'Cancel$'" ref'))
  1139.           call AssignID('GE_UndoGad', ToPIPE('GE', 'button weiw=0 weih=0 dis=1 gt="'Undo$'" ref'))
  1140.         call ToPIPE('GE', 'le')
  1141.       call ToPIPE('GE', 'le')
  1142.     call ToPIPE('GE', 'le')
  1143.   call ToPIPE('GE', 'le')
  1144.  
  1145.   GetFileAllGad = ToPIPE('GE', 'getfile ua pat="#?"')
  1146.   GetFileDataGad = ToPIPE('GE', 'getfile ua pat="'PatVar'"')
  1147.  
  1148.   if App == 'PGS' then do
  1149.     call open('FontReq', "awnpipe:FontReq/xc")
  1150.     call ToPIPE('FontReq', '"'SelectFont$'" m db dg v a ps="'AppScreen'"')
  1151.     call ToPIPE('FontReq', 'listbrowser minw=200 minh=300')
  1152.     do GE_FontNumber = 0 to FontList.COUNT - 1
  1153.       GadID = ToPIPE('FontReq', 'browsernode gt="'FontList.GE_FontNumber'" ref')
  1154.       interpret 'FontGad.'GadID' = 'GE_FontNumber
  1155.     end
  1156.   end
  1157.  
  1158.   call open('ColorReq','awnpipe:ColorReq/xc')
  1159.   call ToPIPE('ColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  1160.   call ToPIPE('ColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample" ref')
  1161.  
  1162.   call open('NCColorReq','awnpipe:NCColorReq/xc')
  1163.   call ToPIPE('NCColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  1164.   call ToPIPE('NCColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample" ref')
  1165.  
  1166.   if App == 'FW' then do
  1167.     do GE_ColorNumber = 0 to ColorList.Count - 2
  1168.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  1169.       RPen = dTox(x2d(left(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  1170.       GPen = dTox(x2d(substr(ColorRegister.GE_ColorNumber, 3, 2)) / 255 * 4294967295)
  1171.       BPen = dTox(x2d(right(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  1172.  
  1173.       call ToPIPE('ColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  1174.       GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶" ref')
  1175.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  1176.  
  1177.       call ToPIPE('NCColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  1178.       GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶" ref')
  1179.       interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  1180.     end
  1181.     GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|¶" ref')
  1182.     interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  1183.   end
  1184.   else if App == 'PGS' then do
  1185.     do GE_ColorNumber = 0 to ColorList.Count - 2
  1186.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  1187.       GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|" ref')
  1188.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  1189.       GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|" ref')
  1190.       interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  1191.     end
  1192.     GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|" ref')
  1193.     interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  1194.   end
  1195.  
  1196. /**/
  1197.  
  1198.   /***//*** GUI Action Loop ***/
  1199.   call ToPIPE('GE', 'open')
  1200.   call UpdateBusy(Req, 1)
  1201.  
  1202.   call CloseBusy('ProgReq')
  1203.  
  1204.   do until eof('GE')
  1205.     call ToPIPE('GE', 'continue')
  1206.     GE_EventInfo = readln('GE')
  1207.     parse var GE_EventInfo GE_Event' 'GE_GadID' 'GE_GadInfo1
  1208.     select
  1209.     /***//*** close ***/
  1210.       when GE_Event == 'close' then call Cleanup
  1211.     /**/
  1212.  
  1213.     /***//*** Help event ***/
  1214.       when GE_Event == 'help' then do
  1215.         if GE_GadID ~= -1 then OverGad = GE_GadID
  1216.       end
  1217.     /**/
  1218.  
  1219.     /***//*** Key event ***/
  1220.       when GE_Event == 'key' then do
  1221.         HelpGad = GE_Help.OverGad
  1222.         interpret 'HelpText = Help$.'HelpGad
  1223.         if (GE_GadID == 95) & (symbol('Help$.'HelpGad) == 'VAR') then
  1224.           call CASimpleReq(Help$, HelpText, HelpTime)
  1225.       end
  1226.     /**/
  1227.  
  1228.     /***//*** GE_EventTypeGad ***/
  1229.       when GE_GadID == GE_EventTypeGad then do
  1230.         GE_EventType = GE_Type.GE_GadInfo1
  1231.         interpret 'GE_EventValue = GE_Store'GE_EventType'$'
  1232.         GE_StartOrEnd = 1
  1233.         if GE_EventType == Event$ then GE_DisableFlag = 0
  1234.         else do
  1235.           GE_DisableFlag = 1
  1236.           call ToPIPE('GE', 'id 'GE_EndGad' gt="" ref')
  1237.         end
  1238.         call ToPIPE('GE', 'id 'GE_EventGad' gt="'GE_EventValue'" ref')
  1239.         call ToPIPE('GE', 'id 'GE_ChooseFileGad' dis='1-GE_DisableFlag' ref')
  1240.         call ToPIPE('GE', 'id 'GE_FontNameGad' dis='GE_DisableFlag' ref')
  1241.         call ToPIPE('GE', 'id 'GE_FontSizeGad' dis='GE_DisableFlag' ref')
  1242.         call ToPIPE('GE', 'id 'GE_ChooseFontGad' dis='GE_DisableFlag' ref')
  1243.         call ToPIPE('GE', 'id 'GE_ResetGad' dis='GE_DisableFlag' ref')
  1244.         call ToPIPE('GE', 'id 'GE_TextColorGad' dis='GE_DisableFlag' ref')
  1245.         call ToPIPE('GE', 'id 'GE_LineGad' dis='GE_DisableFlag' ref')
  1246.         call ToPIPE('GE', 'id 'GE_BoxedGad' dis='GE_DisableFlag' ref')
  1247.         call ToPIPE('GE', 'id 'GE_BoxColorGad' dis='GE_DisableFlag' ref')
  1248.         call ToPIPE('GE', 'id 'GE_FrequencyGad' dis='GE_DisableFlag' ref')
  1249.       end
  1250.     /**/
  1251.  
  1252.     /***//*** GE_EventGad ***/
  1253.       when GE_GadID == GE_EventGad then do
  1254.         GE_EventValue = GE_GadInfo1
  1255.         interpret 'GE_Store'GE_EventType'$ = GE_EventValue'
  1256.       end
  1257.     /**/
  1258.  
  1259.     /***//*** GE_ChooseFileGad ***/
  1260.       when GE_GadID == GE_ChooseFileGad then do
  1261.         if GE_EventType == Image$ then do
  1262.           address command 'assign >NIL: FWC: 'ScriptDir'Images/'
  1263.           if RC == 20 then GE_Dir = ScriptDir
  1264.           else do
  1265.             GE_Dir = ScriptDir'Images/'
  1266.             address command 'assign >NIL: FWC:'
  1267.           end
  1268.           GE_EventFile = CAGetFile('GE', GetFileAllGad, SelectImage$, GE_Dir)
  1269.         end
  1270.         else do
  1271.           GE_EventFile = CAGetFile('GE', GetFileDataGad, SelectFile$, PathPart(PrefsFile)'FWCAddEvent.data')
  1272.         end
  1273.  
  1274.         if GE_EventFile ~= '' then do
  1275.           if ~exists(GE_EventFile) then do
  1276.             call ToPIPE('GE', 'id 0 s=256')
  1277.             call CASimpleReq('FWCAddEvent 'Notice$, GE_EventFile' 'CantFind$'...')
  1278.             call ToPIPE('GE', 'id 0 s=512')
  1279.             GE_EventFile = ''
  1280.           end
  1281.           else do
  1282.             GE_EventValue = GE_EventFile
  1283.             interpret 'GE_Store'GE_EventType'$ = GE_EventValue'
  1284.             call ToPIPE('GE', 'id 'GE_EventGad' gt="'GE_EventValue'" ref')
  1285.           end
  1286.         end
  1287.       end
  1288.     /**/
  1289.  
  1290.     /***//*** GE_FontNameGad ***/
  1291.       when GE_GadID == GE_FontNameGad then do
  1292.         call ToPIPE('GE', 'id 0 s=256')
  1293.         call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  1294.         call ToPIPE('GE', 'id 0 s=512')
  1295.         call ToPIPE('GE', 'id 'GE_FontNameGad' gt="'FontName'" ref')
  1296.       end
  1297.     /**/
  1298.  
  1299.     /***//*** GE_FontSizeGad ***/
  1300.       when GE_GadID == GE_FontSizeGad then do
  1301.         interpret 'Value = 'GE_GadInfo1
  1302.         if datatype(Value) == 'NUM' then FontSize = round(Value, 4)
  1303.         call ToPIPE('GE', 'id 'GE_FontSizeGad' gt="'FontSize'" ref')
  1304.       end
  1305.     /**/
  1306.  
  1307.     /***//*** GE_ChooseFontGad ***/
  1308.       when GE_GadID == GE_ChooseFontGad then do
  1309.         if App == 'FW' then do
  1310.           GE_File = CAGetFile('GE', GetFileAllGad, SelectFont$, CurrentDir'FWFonts/SWOLFonts/')
  1311.           if GE_File ~= '' then do
  1312.             FontName = GE_File
  1313.             call ToPIPE('GE', 'id 'GE_FontNameGad' gt="'FontName'" ref')
  1314.           end
  1315.         end
  1316.         else if App == 'PGS' then do
  1317.           call ToPIPE('GE', 'id 0 s=256')
  1318.             FontName = ReadBrowserList('FontReq', 'FontGad', 'FontList', FontName)
  1319.             call ToPIPE('GE', 'id 'GE_FontNameGad' gt="'FontName'" ref')
  1320.           call ToPIPE('GE', 'id 0 s=512')
  1321.         end
  1322.       end
  1323.     /**/
  1324.  
  1325.     /***//*** GE_ResetGad ***/
  1326.       when GE_GadID == GE_ResetGad then do
  1327.         FontName = Font.Highlight
  1328.         FontSize = FSize.Highlight
  1329.         call ToPIPE('GE', 'id 'GE_FontNameGad' gt="'FontName'"')
  1330.         call ToPIPE('GE', 'id 'GE_FontSizeGad' gt="'FontSize'"')
  1331.       end
  1332.     /**/
  1333.  
  1334.     /***//*** Date Gadgets ***/
  1335.       when GadArg.GE_GadID ~= '' then do
  1336.         if GE_EventType == File$ then GE_StartOrEnd = 0
  1337.         else GE_StartOrEnd = 1 - GE_StartOrEnd
  1338.         GE_ReturnDate = strip(left(GadArg.GE_GadID, 1)''right(GadArg.GE_GadID, 2), "B", "C")
  1339.         GE_Date = substr(GadArg.GE_GadID, 2)
  1340.         if GE_StartOrEnd == 0 then do
  1341.           call ToPIPE('GE', 'id 'GE_StartGad' gt="'GE_Date'" ref')
  1342.           GE_StartDate = GE_ReturnDate
  1343.         end
  1344.         else do
  1345.           call ToPIPE('GE', 'id 'GE_EndGad' gt="'GE_Date'" ref')
  1346.           GE_EndDate = GE_ReturnDate
  1347.         end
  1348.       end
  1349.     /**/
  1350.  
  1351.     /***//*** GE_TextColorGad ***/
  1352.       when GE_GadID == GE_TextColorGad then do
  1353.         call ToPIPE('GE', 'id 0 s=256')
  1354.         GE_TextColor = ReadBrowserList('NCColorReq', 'NCColorGad', 'ColorList')
  1355.         call ToPIPE('GE', 'id 'GE_TextColorGad' gt="'GE_TextColor'"')
  1356.         call ToPIPE('GE', 'id 0 s=512')
  1357.       end
  1358.     /**/
  1359.  
  1360.     /***//*** GE_LineGad ***/
  1361.       when GE_GadID == GE_LineGad then GE_EnteredLine = GE_GadInfo1
  1362.     /**/
  1363.  
  1364.     /***//*** GE_BoxedGad ***/
  1365.       when GE_GadID == GE_BoxedGad then GE_BoxValue = GE_Boxed.GE_GadInfo1
  1366.     /**/
  1367.  
  1368.     /***//*** GE_BoxColorGad ***/
  1369.       when GE_GadID == GE_BoxColorGad then do
  1370.         call ToPIPE('GE', 'id 0 s=256')
  1371.         GE_BoxColor = ReadBrowserList('ColorReq', 'ColorGad', 'ColorList')
  1372.         call ToPIPE('GE', 'id 'GE_BoxColorGad' gt="'GE_BoxColor'"')
  1373.         call ToPIPE('GE', 'id 0 s=512')
  1374.       end
  1375.     /**/
  1376.  
  1377.     /***//*** GE_FrequencyGad ***/
  1378.       when GE_GadID == GE_FrequencyGad then GE_WeeklyValue = GE_Weekly.GE_GadInfo1
  1379.     /**/
  1380.  
  1381.     /***//*** GE_UndoGad ***/
  1382.       when GE_GadID == GE_UndoGad then do
  1383.         call ToPIPE('GE', 'id 0 s=128')
  1384.           do GE_i = 1 to Undo.UndoLevel.0
  1385.             if App == 'FW' then DELETEOBJECT Undo.UndoLevel.GE_i
  1386.             else if App == 'PGS' then do
  1387.               SELECTOBJECT OBJECTID Undo.UndoLevel.GE_i WINDOW winName
  1388.               DELETEOBJECT OBJECTID Undo.UndoLevel.GE_i WINDOW winName
  1389.             end
  1390.           end
  1391.           UndoLevel = UndoLevel - 1
  1392.           if UndoLevel == 0 then UndoStatus = 1
  1393.           else UndoStatus = 0
  1394.           call ToPIPE('GE', 'id 'GE_UndoGad' dis='UndoStatus' ref')
  1395.         call ToPIPE('GE', 'id 0 s=64')
  1396.       end
  1397.     /**/
  1398.  
  1399.     /***//*** GE_OKGad ***/
  1400.       when GE_GadID == GE_OKGad then do
  1401.         call writeln('GE', 'id 'GE_EventGad' read')
  1402.         GE_EventValue = readln('GE')
  1403.         call writeln('GE', 'id 'GE_FontSizeGad' read')
  1404.         FontSize = readln('GE')
  1405.         if (GE_StartDate == "") & (GE_EventType == Event$) then do
  1406.           call ToPIPE('GE', 'id 0 s=256')
  1407.           call CASimpleReq('FWCAddEvent 'Notice$, EnterStartDate$'...')
  1408.           call ToPIPE('GE', 'id 0 s=512')
  1409.         end
  1410.         else if (GE_EventValue == "") & (GE_BoxValue == "") then do
  1411.           call ToPIPE('GE', 'id 0 s=256')
  1412.           call CASimpleReq('FWCAddEvent 'Notice$, EnterEvent$'...')
  1413.           call ToPIPE('GE', 'id 0 s=512')
  1414.         end
  1415.         else do
  1416.           EventData = "   EventType = "GE_EventType||'0a'x||,
  1417.                       " EnteredDay1 = "strip(GE_StartDate)||'0a'x||,
  1418.                       " EnteredDay2 = "strip(GE_EndDate)||'0a'x||,
  1419.                       "   TextColor = "GE_TextColor||'0a'x||,
  1420.                       " EnteredLine = "GE_EnteredLine||'0a'x||,
  1421.                       "    BoxColor = "GE_BoxColor||'0a'x||,
  1422.                       "     Options = "GE_BoxValue""GE_WeeklyValue||'0a'x||,
  1423.                       " EnteredFont = "strip(FontName)||'0a'x||,
  1424.                       " EnteredSize = "strip(FontSize)||'0a'x||,
  1425.                       "EnteredEvent = "GE_EventValue
  1426.           call ToPIPE('GE', 'id 0 s=128')
  1427.           call ProcessEvent
  1428.           call ToPIPE('GE', 'id 0 s=64')
  1429.  
  1430.           if UndoLevel == 0 then UndoStatus = 1
  1431.           else UndoStatus = 0
  1432.           call ToPIPE('GE', 'id 'GE_UndoGad' dis='UndoStatus' ref')
  1433.  
  1434.           GE_StartOrEnd = 1
  1435.           GE_StartDate  = ""
  1436.           GE_EndDate    = ""
  1437.           call ToPIPE('GE', 'id 'GE_StartGad' gt="" ref')
  1438.           call ToPIPE('GE', 'id 'GE_EndGad' gt="" ref')
  1439.         end
  1440.       end
  1441.     /**/
  1442.  
  1443.       otherwise nop
  1444.     end
  1445.   end
  1446. /**/
  1447.   exit
  1448. /**/
  1449.  
  1450. /***//*** GetFontWidth (GFW) Subroutine ***/
  1451. GetFontWidth:
  1452.   parse arg GFW_FontType, GFW_Char
  1453.  
  1454.   GFW_ID = PrintText(1, 1, GFW_FontType, 'N', White$, Width.GFW_FontType, GFW_Char)
  1455.   if App == 'FW' then do
  1456.     REDRAW
  1457.     GETOBJECTCOORDS GFW_ID; parse var RESULT . . . GFW_Width .
  1458.     DELETEOBJECT GFW_ID
  1459.   end
  1460.   else if App == 'PGS' then do
  1461.     GETTEXTOBJ POSITION GFW_Text OBJECTID GFW_ID WINDOW winName
  1462.     GFW_Width = GFW_Text.Right - GFW_Text.Left
  1463.     DELETEOBJECT OBJECTID GFW_ID WINDOW winName
  1464.   end
  1465. return GFW_Width
  1466. /**/
  1467.  
  1468. /***//*** GetHeight (GH) Subroutine ***/
  1469. GetHeight:
  1470.   parse arg GH_FontType
  1471.  
  1472.   if App == 'FW' then do
  1473.     TEXTBLOCKTYPEPREFS SIZE FSize.GH_FontType FONT Font.GH_FontType
  1474.     DRAWTEXTBLOCK 1 1 1 'A'; GH_id = result
  1475.     GETOBJECTCOORDS GH_id; Parse Var result . . . . GH_Text.Height
  1476.     DELETEOBJECT GH_id
  1477.   end
  1478.   else if App == 'PGS' then do
  1479.     DRAWTEXTOBJ 0 0 WINDOW winName; GH_id = result
  1480.     SELECTTEXT AT 0 0 WINDOW winName
  1481.     BEGINCOMMANDCAPTURE
  1482.       SETLEADING RELATIVE 100
  1483.       SETTYPESIZE FSize.GH_FontType WINDOW winName
  1484.       SETFONT Font.GH_FontType WINDOW winName
  1485.     ENDCOMMANDCAPTURE
  1486.     INSERT 'A' WINDOW winName
  1487.     GETTEXTOBJ POSITION GH_Text OBJECTID GH_id WINDOW winName
  1488.     GH_Text.Height = GH_Text.Bottom - GH_Text.Top
  1489.     DELETEOBJECT OBJECTID GH_id WINDOW winName
  1490.   end
  1491.   return GH_Text.Height
  1492. /**/
  1493.  
  1494. /***//*** GetID (GI) Subroutine ***/
  1495. GetID:
  1496. parse arg GI_var
  1497.  
  1498. return id.GI_var
  1499. /**/
  1500.  
  1501. /***//*** GetImageInfo (GII) ***/
  1502. GetImageInfo:
  1503.   parse arg GII_ImageNumber
  1504.  
  1505.   if ImageType.GII_ImageNumber == '' then do
  1506.     ImageFile.GII_ImageNumber = strip(ImageFile.GII_ImageNumber, 'B', '" '||"'")
  1507.     parse var ImageFile.GII_ImageNumber ImageFile.GII_ImageNumber ',' ImageDX.GII_ImageNumber ',' ImageDY.GII_ImageNumber
  1508.     ImageDX.GII_ImageNumber = strip(ImageDX.GII_ImageNumber, 'B', '" '||"'");if ImageDX.GII_ImageNumber == '' then ImageDX.GII_ImageNumber = 0
  1509.     ImageDY.GII_ImageNumber = strip(ImageDY.GII_ImageNumber, 'B', '" '||"'");if ImageDY.GII_ImageNumber == '' then ImageDY.GII_ImageNumber = 0
  1510.     if (pos('/', ImageFile.GII_ImageNumber) == 0) & (pos(':', ImageFile.GII_ImageNumber) == 0) then
  1511.       ImageFile.GII_ImageNumber = ScriptDir'Images/'strip(ImageFile.GII_ImageNumber, 'B', ' "'||"'")
  1512.     if upper(GfxApp) == 'FWCALENDAR' then call WriteFile('PIPE:FWC', ParseImage(ImageFile.GII_ImageNumber))
  1513.     else do
  1514.       GII_Cmd = Storage''GfxApp' >PIPE:FWC '
  1515.       GII_InsertPos = pos('%s', GfxCmd)
  1516.       GII_Cmd = GII_Cmd''left(GfxCmd, GII_InsertPos - 1)''ImageFile.GII_ImageNumber''substr(GfxCmd, GII_InsertPos + 2)
  1517.       address command GII_Cmd
  1518.     end
  1519.  
  1520.     GII_Template = GfxTemplate
  1521.     GII_InfoLine = ReadFile('PIPE:FWC')
  1522.     if GII_InfoLine ~= '' then do
  1523.       interpret "parse var GII_InfoLine "GII_Template
  1524.       GII_ImageType = upper(strip(ImgDT))
  1525.       ImageWidth.GII_ImageNumber = strip(ImgWidth) / 72
  1526.       ImageHeight.GII_ImageNumber = strip(ImgHeight) / 72
  1527.       if (datatype(GII_ImageType) ~= 'CHAR') | (datatype(ImageWidth.GII_ImageNumber) ~= 'NUM') | (datatype(ImageHeight.GII_ImageNumber) ~= 'NUM') then do
  1528.         call AddMsg('W', GII_InfoLine)
  1529.         return 0
  1530.       end
  1531.       else do
  1532.         if (GII_ImageType == 'POST') | (GII_ImageType == 'POSTSCRIPT') then do
  1533.           call open('File', ImageFile.GII_ImageNumber)
  1534.             GII_FileInfo = readch('File', 15)
  1535.             if left(GII_FileInfo, 14) == '%!PS-Adobe-3.0' then GII_ImageType = 'EPS'
  1536.             else GII_ImageType = 'POST'
  1537.           call close('File')
  1538.         end
  1539.         else if (GII_ImageType == 'WINDOWS BITMAP') | (GII_ImageType == 'WIND') then GII_ImageType = 'BMP'
  1540.         ImageType.GII_ImageNumber = GII_ImageType
  1541.         if PGSFilter.GII_ImageType == '' then PGSFilter.GII_ImageNumber = GII_ImageType
  1542.         else PGSFilter.GII_ImageNumber = PGSFilter.GII_ImageType
  1543.       end
  1544.     end
  1545.     else do
  1546.       call AddMsg('W', 'Unable to process 'ImageFile.GII_ImageNumber)
  1547.       return 0
  1548.     end
  1549.   end
  1550.  
  1551.   return 1
  1552. /**/
  1553.  
  1554. /***//*** GetWidth (GW) Subroutine ***/
  1555. GetWidth:
  1556.   parse arg GW_ID
  1557.  
  1558.   if App = 'FW' then do
  1559.     GETOBJECTCOORDS GW_ID
  1560.     Parse Var result . . . GW_width .
  1561.   end
  1562.   else if App == 'PGS' then do
  1563.     SELECTOBJECT OBJECTID GW_ID  WINDOW winName
  1564.     GETOBJECT BOUNDINGBOX GW_Temp WINDOW winName
  1565.     GW_width = GW_Temp.Right - GW_Temp.Left
  1566.   end
  1567.  
  1568.   return GW_width
  1569. /**/
  1570.  
  1571. /***//*** InsertImage (II) ***/
  1572. InsertImage:
  1573.   parse arg II_ImageNumber, II_CenterX, II_CenterY, II_MaxWidth, II_MaxHeight, II_FixRatio
  1574.  
  1575.   if GoodImage.II_ImageNumber == 0 then return 0
  1576.  
  1577.   if ImageType.II_ImageNumber == '' then GoodImage.II_ImageNumber = GetImageInfo(II_ImageNumber)
  1578.   if ImageType.II_ImageNumber ~= '' then do
  1579.     II_ImageWidth = ImageWidth.II_ImageNumber
  1580.     II_ImageHeight = ImageHeight.II_ImageNumber
  1581.     if (II_MaxWidth > 0) & (II_MaxHeight > 0) then do
  1582.       if II_FixRatio == 1 then do
  1583.         if (II_ImageWidth > II_MaxWidth) | (II_ImageHeight > II_MaxHeight) then do
  1584.           EnlFactor = min(II_MaxWidth / II_ImageWidth, II_MaxHeight / II_ImageHeight)
  1585.           II_ImageWidth  = II_ImageWidth * EnlFactor
  1586.           II_ImageHeight = II_ImageHeight * EnlFactor
  1587.         end
  1588.       end
  1589.       else do
  1590.         if II_MaxWidth > 0 then II_ImageWidth  = II_ImageWidth * (II_MaxWidth / II_ImageWidth)
  1591.         if II_MaxHeight > 0 then II_ImageHeight = II_ImageHeight * (II_MaxHeight / II_ImageHeight)
  1592.       end
  1593.     end
  1594.     II_Image.Left = II_CenterX - II_ImageWidth/2 + ImageDX.II_ImageNumber
  1595.     II_Image.Top  = II_CenterY - II_ImageHeight/2 + ImageDY.II_ImageNumber
  1596.     if App == 'FW' then do
  1597.       INSERTIMAGE ImageFile.II_ImageNumber POSITION 1 II_Image.Left II_Image.Top II_ImageWidth II_ImageHeight
  1598.       ImageID.Day = result
  1599.       OBJECTTOBACK ImageID.Day
  1600.     end
  1601.     else if App == 'PGS' then do
  1602.       if pos(upper('|'PGSFilter.II_ImageNumber'|'), PGSRecognizedFormats) ~= 0 then do
  1603.         PLACEGRAPHIC FILE ImageFile.II_ImageNumber FILTER PGSFilter.II_ImageNumber AT II_Image.Left II_Image.Top WINDOW winName
  1604.         ImageID.Day = result
  1605.         if PGSFilter.II_ImageNumber == 'IllustratorEPS' then EDITDRAWING POSITION II_Image.Left II_Image.Top (II_Image.Left + II_ImageWidth) (II_Image.Top + II_ImageHeight) OBJECTID ImageID.Day WINDOW winName
  1606.         else EDITPICTURE POSITION II_Image.Left II_Image.Top (II_Image.Left + II_ImageWidth) (II_Image.Top + II_ImageHeight) OBJECTID ImageID.Day WINDOW winName
  1607.         SENDTOBACK OBJECTID ImageID.Day WINDOW winName
  1608.       end
  1609.     end
  1610.   end
  1611.  
  1612.   return ImageID.Day
  1613. /**/
  1614.  
  1615. /***//*** MemberID (MI) ***/
  1616. MemberID:
  1617.   parse arg MI_Member, MI_Array, MI_Count, MI_Start
  1618.  
  1619.   if MI_Count == '' then interpret 'MI_Count = 'MI_Array'.Count'
  1620.   if MI_Start == '' then do
  1621.     if symbol(MI_Array'.Start') == 'VAR' then interpret 'MI_Start = 'MI_Array'.Start'
  1622.     else MI_Start = 0
  1623.   end
  1624.  
  1625.   do MI_i = MI_Start to MI_Start + MI_Count - 1
  1626.     if upper(value(MI_Array'.'MI_i)) == upper(MI_Member) then return MI_i
  1627.   end
  1628.   return -1
  1629. /**/
  1630.  
  1631. /***//*** NameOnly (PROCEDURE) ***/
  1632. NameOnly: PROCEDURE
  1633.   parse arg FileWithPath
  1634.   return substr(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)) + 1)
  1635. /**/
  1636.  
  1637. /***//*** ParseImage (PROCEDURE) ***/
  1638. ParseImage: PROCEDURE
  1639.   parse arg FileName
  1640.  
  1641.   BytesRead = 1000
  1642.   call open('File', FileName)
  1643.     FileInfo = readch('File', BytesRead)
  1644.  
  1645.     Dimensions = 0
  1646.     XSize = 0
  1647.     YSize = 0
  1648.     Select
  1649.       when left(FileInfo, 2) == 'BM' then Dimensions = DoBMP()
  1650.       when left(FileInfo, 4) == 'FORM' then Dimensions = DoIFF()
  1651.       when left(FileInfo, 3) == 'GIF' then Dimensions =  DoGIF()
  1652.       when left(FileInfo, 10) == '%!PS-Adobe' then Dimensions = DoPS()
  1653.       when left(FileInfo, 5) == x2c(C5D0D3C61E) then Dimensions = DoPS()
  1654.       when left(FileInfo, 4) == x2c(0A050108) then Dimensions = DoPCX()
  1655.       when left(FileInfo, 4) == x2c(4D4D002A) then Dimensions = DoTIFF(1)
  1656.       when left(FileInfo, 4) == x2c(49492A00) then Dimensions = DoTIFF(2)
  1657.       when substr(FileInfo, 2, 3) == 'PNG' then Dimensions = DoPNG()
  1658.       when substr(FileInfo, 7, 4) == 'JFIF' then Dimensions = DoJPEG()
  1659.       when substr(FileInfo, 9, 4) == x2c(00000763) then Dimensions = DoTarga()
  1660.       otherwise FileType = 'Unknown'
  1661.     end
  1662.     if Dimensions ~= 0 then parse var Dimensions XSize'x'YSize
  1663.   call close('File')
  1664.   return FileType' 'XSize' 'YSize
  1665.  
  1666. /* Format Routines */
  1667. /***//** BMP **/
  1668. DoBMP:
  1669.   FileType = 'BMP'
  1670.   XSize = x2d(c2x(substr(FileInfo, 21, 1)||substr(FileInfo, 20, 1)||substr(FileInfo, 19, 1)))
  1671.   YSize = x2d(c2x(substr(FileInfo, 25, 1)||substr(FileInfo, 24, 1)||substr(FileInfo, 23, 1)))
  1672.   return XSize'x'YSize
  1673. /**/
  1674.  
  1675. /***//** EPS **/
  1676. DoEPS:
  1677.   FileType = 'EPS'
  1678.   BoundingBoxLn = ReadToEOL(pos('%%BoundingBox:', FileInfo), FileInfo)
  1679.   BoundingBox = substr(BoundingBoxLn, pos(':', BoundingBoxLn) + 1)
  1680.   XSize = word(BoundingBox, 3) - word(BoundingBox, 1) + 1
  1681.   YSize = word(BoundingBox, 4) - word(BoundingBox, 2) + 1
  1682.  
  1683.   return XSize'x'YSize
  1684. /**/
  1685.  
  1686. /***//** GIF **/
  1687. DoGIF:
  1688.   if (left(FileInfo, 6) == 'GIF89a') | (left(FileInfo, 6) == 'GIF87a')then do
  1689.     FileType = 'GIF'
  1690.     XSize = x2d(c2x(substr(FileInfo, 8, 1)||substr(FileInfo, 7, 1)))
  1691.     YSize = x2d(c2x(substr(FileInfo, 10, 1)||substr(FileInfo, 9, 1)))
  1692.     return XSize'x'YSize
  1693.   end
  1694.   return 0
  1695. /**/
  1696.  
  1697. /***//** IFF **/
  1698. DoIFF:
  1699.   SubType  = substr(FileInfo, 9, 4)
  1700.   FileType = 'IFF'SubType
  1701.  
  1702.   if pos(SubType, 'ILBM|DEEP|RGBN|RGB8') > 0 then do
  1703.     OffSet = pos('BMHD', FileInfo)
  1704.     if OffSet == 0 then OffSet = pos('DGBL', FileInfo)
  1705.     if OffSet > 0 then do
  1706.       XSize = x2d(c2x(substr(FileInfo, OffSet + 8, 2)))
  1707.       YSize = x2d(c2x(substr(FileInfo, OffSet + 10, 2)))
  1708.       return XSize'x'YSize
  1709.     end
  1710.   end
  1711.   return 0
  1712. /**/
  1713.  
  1714. /***//** JPEG **/
  1715. DoJPEG:
  1716.   FileType = 'JPEG'
  1717.   Offset = x2d(c2x(substr(FileInfo, 5, 2))) + 7
  1718.   if x2d(c2x(substr(FileInfo, Offset, 1))) ~= 0 then do
  1719.     Offset = x2d(c2x(substr(FileInfo, 23, 2))) + 25
  1720.     if Offset > BytesRead then do
  1721.       BytesRead = BytesRead + Offset
  1722.       FileInfo = FileInfo||readch('File', Offset)
  1723.     end
  1724.  
  1725.     Offset = x2d(c2x(substr(FileInfo, Offset, 2))) + Offset
  1726.     if Offset > BytesRead then do
  1727.       BytesRead = BytesRead + Offset
  1728.       FileInfo = FileInfo||readch('File', Offset)
  1729.     end
  1730.   end
  1731.  
  1732.   Offset = pos(x2c(001108), FileInfo, Offset)
  1733.   if Offset == 0 then Offset = pos(x2c(001108), FileInfo, Offset)
  1734.   if Offset > 0 then do
  1735.     YSize = x2d(c2x(substr(FileInfo, Offset+3, 2)))
  1736.     XSize = x2d(c2x(substr(FileInfo, Offset + 5, 2)))
  1737.     return XSize'x'YSize
  1738.   end
  1739.  
  1740.   return 0
  1741. /**/
  1742.  
  1743. /***//** PCX **/
  1744. DoPCX:
  1745.   FileType = 'PCX'
  1746.   XSize = x2d(c2x(substr(FileInfo, 14, 1)||substr(FileInfo, 13, 1)))
  1747.   YSize = x2d(c2x(substr(FileInfo, 16, 1)||substr(FileInfo, 15, 1)))
  1748.   return XSize'x'YSize
  1749. /**/
  1750.  
  1751. /***//** PNG **/
  1752. DoPNG:
  1753.   FileType = 'PNG'
  1754.   OffSet = pos('IHDR', FileInfo)
  1755.   if Offset > 0 then do
  1756.     XSize = x2d(c2x(substr(FileInfo, Offset + 6, 2)))
  1757.     YSize = x2d(c2x(substr(FileInfo, Offset + 10, 2)))
  1758.     return XSize'x'YSize
  1759.   end
  1760.   return 0
  1761. /**/
  1762.  
  1763. /***//** PS **/
  1764. DoPS:
  1765.   FileType = 'POST'
  1766.   BoundingBoxLn = ReadToEOL(pos('%%BoundingBox:', FileInfo), FileInfo)
  1767.   BoundingBox = substr(BoundingBoxLn, pos(':', BoundingBoxLn) + 1)
  1768.   if datatype(word(BoundingBox, 1)) ~= 'NUM' then return 0
  1769.   XSize = word(BoundingBox, 3) - word(BoundingBox, 1) + 1
  1770.   YSize = word(BoundingBox, 4) - word(BoundingBox, 2) + 1
  1771.  
  1772.   return XSize'x'YSize
  1773. /**/
  1774.  
  1775. /***//** Targa **/
  1776. DoTarga:
  1777.   FileType = 'TARGA'
  1778.   XSize = x2d(c2x(substr(FileInfo, 14, 1)||substr(FileInfo, 13, 1)))
  1779.   YSize = x2d(c2x(substr(FileInfo, 16, 1)||substr(FileInfo, 15, 1)))
  1780.   return XSize'x'YSize
  1781. /**/
  1782.  
  1783. /***//** TIFF **/
  1784. DoTIFF:
  1785.   parse arg TIFFType
  1786.   FileType = 'TIFF'
  1787.   if TIFFType == 1 then do
  1788.     XSize = x2d(c2x(substr(FileInfo, 21, 2)))
  1789.     YSize = x2d(c2x(substr(FileInfo, 33, 2)))
  1790.   end
  1791.   else do
  1792.     XSize = x2d(c2x(substr(FileInfo, 22, 1)||substr(FileInfo, 21, 1)))
  1793.     YSize = x2d(c2x(substr(FileInfo, 34, 1)||substr(FileInfo, 33, 1)))
  1794.   end
  1795.   return XSize'x'YSize
  1796. /**/
  1797. /**/
  1798.  
  1799. /***//*** ParseVariables (PV) Subroutine ***/
  1800. ParseVariables:
  1801.   parse arg PV_Line
  1802.  
  1803.   PV_String = translate(PV_Line,,'=(+-*/,)"'||"'",' ')
  1804.   PV_VarString = ''
  1805.   PV_Var.      = '00'x
  1806.   PV_LongVar   = 4
  1807.   PV_LIT       = ''
  1808.   PV_Count     = 0
  1809.  
  1810.   do PV_i = 1 to words(PV_String)
  1811.     PV_Word = word(PV_String, PV_i)
  1812.     if pos(PV_Word'(', PV_Line) > 0 then iterate
  1813.     if datatype(PV_Word) == 'CHAR' then do
  1814.       if symbol(PV_Word) == 'LIT' then PV_LIT = PV_LIT''PV_Word', '
  1815.       if symbol(PV_Word) == 'VAR' then do
  1816.         PV_LongVar = max(PV_LongVar, length(PV_Word) + 2)
  1817.         if PV_Var.PV_Word == '00'x then do
  1818.           PV_Count = PV_Count + 1
  1819.           PV_Var.PV_Count = PV_Word
  1820.           PV_Var.PV_Word  = value(PV_Word)
  1821.         end
  1822.         if pos('.', PV_Word) > 0 then do
  1823.           PV_CompoundParts = subword(translate(PV_Word,,'.', ' '), 2)
  1824.           do PV_j = 1 to words(PV_CompoundParts)
  1825.             PV_Subword = word(PV_CompoundParts, PV_j)
  1826.             if PV_Var.PV_SubWord == '00'x then do
  1827.               PV_Count = PV_Count + 1
  1828.               PV_Var.PV_Count = PV_SubWord
  1829.               if symbol(PV_Subword) == 'LIT' then PV_Var.PV_SubWord  = 'LIT'
  1830.               else PV_Var.PV_SubWord  = value(PV_SubWord)
  1831.             end
  1832.           end
  1833.         end
  1834.       end
  1835.     end
  1836.   end
  1837.  
  1838.   do PV_i = 1 to PV_Count
  1839.     PV_Word = PV_Var.PV_i
  1840.     if length(PV_Var.PV_Word) > 50 then PV_Var.PV_Word = left(PV_Var.PV_Word, 50)'...'
  1841.     PV_Var.PV_Word = translate(PV_Var.PV_Word,,'0a'x||'0d'x||'00'x,'bb'x)
  1842.     PV_VarString = PV_VarString''right(PV_Word, PV_LongVar)' = 'PV_Var.PV_Word||'0a'x
  1843.   end
  1844.  
  1845.   if PV_LIT ~= '' then PV_VarString = right('LIT', PV_LongVar)' = 'strip(PV_LIT, 'B', ' ,')||'0a'x||PV_VarString
  1846.  
  1847.   return PV_VarString
  1848. /**/
  1849.  
  1850. /***//*** PathPart (PROCEDURE) ***/
  1851. PathPart: PROCEDURE
  1852.   parse arg FileWithPath
  1853.   return left(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)))
  1854. /**/
  1855.  
  1856. /***//*** PgmVer (PROCEDURE) ***/
  1857. PgmVer: PROCEDURE
  1858.   parse arg Program
  1859.  
  1860.   address command 'version 'Program '>PIPE:FWC file'
  1861.  
  1862.   return strip(word(ReadFile('PIPE:FWC'), 2))
  1863. /**/
  1864.  
  1865. /***//*** PrintText (PT) Subroutine ***/
  1866. PrintText:
  1867.   parse arg PT_Left, PT_Top, PT_FontType, PT_Style, PT_Color, PT_Width, PT_Text
  1868.  
  1869.   if upper(PT_Style) == 'N' then PT_Font = Font.PT_FontType
  1870.   else PT_Font = Bold.PT_FontType
  1871.  
  1872.   if App == 'FW' then do
  1873.     if left(PT_Text, 1) == '"' then PT_Text = '""'PT_Text
  1874.     PT_Top = PT_Top + TextAdj * Height.PT_FontType
  1875.     TEXTBLOCKTYPEPREFS SIZE FSize.PT_FontType WIDTH trunc(PT_Width) COLOR '"'PT_Color'"' FONT PT_Font
  1876.     DRAWTEXTBLOCK 1 PT_Left PT_Top PT_Text; PT_id = result
  1877.   end
  1878.   else if App == 'PGS' then do
  1879.     DRAWTEXTOBJ PT_Left PT_Top WINDOW winName; PT_id = result
  1880.     SELECTTEXT AT PT_Left PT_Top WINDOW winName
  1881.     BEGINCOMMANDCAPTURE
  1882.       SETLEADING RELATIVE 100
  1883.       SETTYPESIZE FSize.PT_FontType WINDOW winName
  1884.       SETTYPEWIDTH PT_Width WINDOW winName
  1885.       SETFONT PT_Font WINDOW winName
  1886.       SETCOLORSTYLE '"'PT_Color'"' COLORNUMBER 0 FILL TEXT WINDOW winName
  1887.     ENDCOMMANDCAPTURE
  1888.     if pos('"', PT_Text) > 0 then do
  1889.       call WriteFile('PIPE:Text2Insert.txt', PT_Text)
  1890.       INSERTTEXT FILE 'PIPE:Text2Insert.txt' FILTER ASCII WINDOW winName
  1891.     end
  1892.     else INSERT '"'PT_Text'"' WINDOW winName
  1893.   end
  1894.   return PT_id
  1895. /**/
  1896.  
  1897. /***//*** ProcessEvent (PE) Subroutine ***/
  1898. ProcessEvent:
  1899.   UndoLevel = UndoLevel + 1
  1900.   UndoItem = 0
  1901.   EnteredLine = 1
  1902.   WindowRefreshed = 0
  1903.   Keywords = '|FONT|SIZE|START|END|LINE|PERIODICBASE|INTERVAL|DURATION|EVENT|EVENTTYPE|OPTIONS|TEXTCOLOR|BOXCOLOR|ENTEREDFONT|ENTEREDSIZE|ENTEREDDAY1|ENTEREDDAY2|ENTEREDLINE|ENTEREDEVENT|'
  1904.   PE_Keywords = '|PERIODICBASE|INTERVAL|DURATION|'
  1905.  
  1906.   if EventData == 0 then call CleanUp
  1907.   call openv('EventData')
  1908.     do until eofv('EventData')
  1909.       PE_Ln = readvln('EventData')
  1910.       interpret strip(word(PE_Ln, 1))' = strip(subword(PE_Ln, 3))'
  1911.     end
  1912.   call closev('EventData')
  1913.  
  1914.   Event. = ''
  1915.   PeriodicEvent. = 0
  1916.   if (EventType == Event$) | (EventType == Image$) then do
  1917.     EventCount = 1
  1918.     Event.0   = EventCount
  1919.     Event.1   = EventData
  1920.     EventFile = ''
  1921.   end
  1922.   else do
  1923.     EventFile = EnteredEvent
  1924.     if EnteredDay1 == '' then EnteredDay1 = 0
  1925.     RootDay = ConvertDay(EnteredDay1)
  1926.  
  1927.     call open('EventFile', EventFile)
  1928.       EventCount = 1
  1929.       do until eof('EventFile')
  1930.         Ln = ReadLn('EventFile')
  1931.         if eof('EventFile') == 0 then do
  1932.           PE_Variable = upper(strip(word(Ln, 1)))
  1933.           if (pos('|'PE_Variable'|', Keywords) == 0) & (Ln ~= '') then do
  1934.             if left(Ln, 1) == '#' then do
  1935.               InternalVariable = word(Ln, 1)
  1936.               interpret InternalVariable'= strip(subword(Ln, 3))'
  1937.               InternalVariable.InternalVariable = value(InternalVariable)
  1938.             end
  1939.             else interpret Ln
  1940.             iterate
  1941.           end
  1942.           if Ln == '' then do
  1943.             if Event.1 ~= '' then EventCount = EventCount + 1
  1944.             iterate
  1945.           end
  1946.           Event.EventCount = Event.EventCount''Ln||'0a'x
  1947.           if PE_Variable == 'PERIODICBASE' then PeriodicEvent.EventCount = 1
  1948.         end
  1949.       end
  1950.       Event.0 = EventCount
  1951.     call close('EventFile')
  1952.   end
  1953.  
  1954.   if App == 'PGS' then do
  1955.     REFRESH OFF ALL
  1956.   end
  1957.  
  1958.   do EC = 1 to Event.0
  1959.     if PeriodicEvent.EC == 1 then do
  1960.       PE = Event.EC
  1961.       do EC2 = EC to Event.0 - 1
  1962.         NextEvent = EC2 + 1
  1963.         Event.EC2 = Event.NextEvent
  1964.       end
  1965.       EventCount = EventCount - 1
  1966.       PE_Ln2 = ''
  1967.       PE_Interval = ''
  1968.       PE_Duration = ''
  1969.       call openv('PE')
  1970.         do until eofv('PE')
  1971.           PE_Ln = readvln('PE')
  1972.           PE_Variable = upper(strip(word(PE_Ln, 1)))
  1973.           if pos('|'PE_Variable'|', PE_Keywords) == 0 then PE_Ln2 = PE_Ln2''PE_Ln||'0a'x
  1974.           if PE_Variable == 'PERIODICBASE' then interpret 'PE_Base = 'strip(subword(PE_Ln, 3))
  1975.           if PE_Variable == 'INTERVAL' then interpret 'Interval = 'strip(subword(PE_Ln, 3))
  1976.           if PE_Variable == 'DURATION' then interpret 'Duration = 'strip(subword(PE_Ln, 3))
  1977.         end
  1978.       call closev('PE')
  1979.       if Interval ~= '' then do
  1980.         if Duration == '' then Duration = 1
  1981.         PeriodicBase = DateInfo('I', PE_Base, 'S')
  1982.         IntervalCount = trunc((InternalStartMonth - PeriodicBase) / Interval, 0)
  1983.         do forever
  1984.           NextEvent = PeriodicBase + (IntervalCount * Interval)
  1985.           if NextEvent > InternalEndMonth then do
  1986.             leave
  1987.           end
  1988.           if NextEvent + Duration - 1 >= InternalStartMonth then do
  1989.             if (NextEvent < InternalStartMonth) & (NextEvent + Duration - 1 >= InternalStartMonth) then do
  1990.               EventCount = EventCount + 1
  1991.               Event.EventCount = 'Start = 1'||'0a'x||'End = 'Duration - (InternalStartMonth - NextEvent)||'0a'x||PE_Ln2
  1992.             end
  1993.             else if (NextEvent <= InternalEndMonth) & (NextEvent + Duration - 1 >= InternalEndMonth) then do
  1994.               EventCount = EventCount + 1
  1995.               Event.EventCount = 'Start = 'NextEvent - InternalStartMonth + 1||'0a'x||'End = 'MonthLength.Month||'0a'x||PE_Ln2
  1996.             end
  1997.             else do
  1998.               EventCount = EventCount + 1
  1999.               Event.EventCount = 'Start = 'NextEvent - InternalStartMonth + 1||'0a'x||'End = 'Duration - (InternalStartMonth - NextEvent)||'0a'x||PE_Ln2
  2000.             end
  2001.           end
  2002.           IntervalCount = IntervalCount + 1
  2003.         end
  2004.       end
  2005.       else do
  2006.         call AddMsg('W', 'Periodic event with base date 'PE_Base' does not have an associated Interval; this event set was skipped.')
  2007.         iterate EC
  2008.       end
  2009.     end
  2010.   end
  2011.   Event.0 = EventCount
  2012.  
  2013.   if Event.0 > 1 then Req = OpenBusy(ProcessEvents$, Event.0)
  2014.   do EC = 1 to Event.0
  2015.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2016.     Box          = 0
  2017.     Weekly       = 0
  2018.     EnteredFont  = Font.Highlight
  2019.     EnteredSize  = FSize.Highlight
  2020.     EnteredDay1  = ''
  2021.     EnteredDay2  = ''
  2022.     EnteredLine  = ''
  2023.     EnteredEvent = ''
  2024.     EventType    = ''
  2025.     PeriodicBase = ''
  2026.     Interval     = ''
  2027.     Duration     = ''
  2028.     Options      = ''
  2029.     BoxColor     = ''
  2030.     TextColor    = ''
  2031.  
  2032.     if Event.EC == '' then iterate
  2033.     call openv('Event.EC')
  2034.       do until eofv('Event.EC')
  2035.         PE_Ln = readvln('Event.EC')
  2036.         PE_Variable = upper(strip(word(PE_Ln, 1)))
  2037.         select
  2038.           when PE_Variable == 'FONT' then PE_Variable = 'EnteredFont'
  2039.           when PE_Variable == 'SIZE' then PE_Variable = 'EnteredSize'
  2040.           when PE_Variable == 'START' then PE_Variable = 'EnteredDay1'
  2041.           when PE_Variable == 'END' then PE_Variable = 'EnteredDay2'
  2042.           when PE_Variable == 'LINE' then PE_Variable = 'EnteredLine'
  2043.           when PE_Variable == 'EVENT' then PE_Variable = 'EnteredEvent'
  2044.           when PE_Variable == 'EVENTTYPE' then nop
  2045.           when PE_Variable == 'OPTIONS' then nop
  2046.           when PE_Variable == 'TEXTCOLOR' then nop
  2047.           when PE_Variable == 'BOXCOLOR' then nop
  2048.           when PE_Variable == 'ENTEREDFONT' then nop
  2049.           when PE_Variable == 'ENTEREDSIZE' then nop
  2050.           when PE_Variable == 'ENTEREDDAY1' then nop
  2051.           when PE_Variable == 'ENTEREDDAY2' then nop
  2052.           when PE_Variable == 'ENTEREDLINE' then nop
  2053.           when PE_Variable == 'ENTEREDEVENT' then nop
  2054.           when PE_Variable == 'COMMENT' then nop
  2055.           otherwise PE_Variable = 'Error'
  2056.         end
  2057.         if PE_Variable ~= 'Error' then do
  2058.           interpret PE_Variable'= strip(subword(PE_Ln, 3))'
  2059.           PE_Val = value(PE_Variable)
  2060.           if symbol('InternalVariable.PE_Val') == 'VAR' then interpret PE_Variable' = 'InternalVariable.PE_Val
  2061.         end
  2062.       end
  2063.     call closev('Event.EC')
  2064.     if PE_Variable == 'Error' then do
  2065.       call AddMsg('W', 'Line "'PE_Ln'" does not start with a keyword; this event set was skipped.')
  2066.       iterate EC
  2067.     end
  2068.     EnteredFont = strip(EnteredFont, 'B', '"'||"'")
  2069.     TextColor   = strip(TextColor, 'B', '"'||"'")
  2070.     BoxColor    = strip(BoxColor, 'B', '"'||"'")
  2071.     Options     = compress(upper(strip(Options, 'B', ' "'||"'")))
  2072.  
  2073.     if App == 'FW' then EnteredSize = max(trunc(EnteredSize), 4)
  2074.  
  2075.     FontInfo = compress(EnteredFont''EnteredSize, '. /:')
  2076.     if FontKnown.FontInfo == '' then do
  2077.       HighestFont = HighestFont + 1
  2078.       FontKnown.FontInfo = HighestFont
  2079.       Font.HighestFont = EnteredFont
  2080.       FSize.HighestFont = EnteredSize
  2081.       Height.HighestFont = GetHeight(HighestFont) * Leading/100
  2082.     end
  2083.     CurrentFont = FontKnown.FontInfo
  2084.  
  2085.     If EnteredDay2 == "" then EnteredDay2 = EnteredDay1
  2086.     If EnteredLine == '' then EnteredLine = 1
  2087.     if BoxColor    == '' then BoxColor = Background.AddEvent
  2088.     if TextColor   == '' then TextColor = Color.AddEvent
  2089.  
  2090.     if (EventType == Event$) | (EventType == Image$) then do
  2091.       EnteredDay1 = ConvertDay(EnteredDay1)
  2092.       EnteredDay2 = ConvertDay(EnteredDay2)
  2093.     end
  2094.     else do
  2095.       EnteredDay1 = RootDay + EnteredDay1
  2096.       EnteredDay2 = RootDay + EnteredDay2
  2097.     end
  2098.     if EnteredDay1 > EnteredDay2 then do
  2099.       TempDate = EnteredDay1
  2100.       EnteredDay1 = EnteredDay2
  2101.       EnteredDay2 = TempDate
  2102.     end
  2103.  
  2104.     if pos('B', Options) ~= 0 then Box = 1
  2105.     if pos('W', Options) ~= 0 then Weekly = 1
  2106.     if pos('2', Options) ~= 0 then Weekly = 2
  2107.  
  2108.     /* Process Event */
  2109.     if App == 'PGS' then REFRESH OFF ALL
  2110.  
  2111.     do until Weekly == 0
  2112.       Event = EnteredEvent
  2113.       Line  = EnteredLine
  2114.       Day1  = EnteredDay1
  2115.       Day2  = EnteredDay2
  2116.       Text. = ''
  2117.  
  2118.       if EventType == Image$ then do
  2119.         parse var Event PE_Image','PE_X','PE_Y
  2120.         if exists(PE_Image) then do
  2121.           do PE_ImageCounter = 1 to PE_ImageCount
  2122.             if ImageFile.PE_ImageCounter = PE_Image then leave
  2123.           end
  2124.           if PE_ImageCounter > PE_ImageCount then do
  2125.             PE_ImageCount = PE_ImageCounter
  2126.             ImageFile.PE_ImageCount = Event
  2127.           end
  2128.           PE_CurrentImage = PE_ImageCounter
  2129.         end
  2130.         else EventType = Event$
  2131.       end
  2132.  
  2133.       if Weekly > 0 then do
  2134.         if Day1 > MaxDate then Weekly = -1
  2135.         if Day2 > MaxDate then Day2 = MaxDate
  2136.       end
  2137.  
  2138.       if Weekly ~= -1 then do
  2139.         If Day1 ~= Day2 then Box = 1
  2140.         LineCount = 0
  2141.         do until Day1 > Day2
  2142.           Day1Row = trunc((Day1 + StartDate - 1) / 7)
  2143.           Day2Row = trunc((Day2 + StartDate - 1) / 7)
  2144.           Day1Column = (Day1 + StartDate) - 7 * Day1Row - 1
  2145.           Day2Column = (Day2 + StartDate) - 7 * Day2Row - 1
  2146.           if (Day1Row == 5) & (DoTopExtraWk == 1) then Day1Row = 0
  2147.           if (Day2Row == 5) & (DoTopExtraWk == 1) then Day2Row = 0
  2148.  
  2149.           if Day1Row == Day2Row then do
  2150.             DaySpan = Day2Column - Day1Column + 1
  2151.             NextDay1 = Day1 + DaySpan
  2152.             if (Day1Column + DaySpan - 1) > WeekdayCount then DaySpan = WeekdayCount - Day1Column + 1
  2153.           end
  2154.           else do
  2155.             DaySpan = WeekdayCount + 1 - Day1Column
  2156.             NextDay1 = Day1 + 7 - Day1Column
  2157.           end
  2158.  
  2159.           if Day1 < 1 then CalDate = MonthLength.PrevMonth + Day1
  2160.           else if Day1 > MonthLength.Month then CalDate = Day1 - MonthLength.Month
  2161.           else CalDate = Day1
  2162.           if DoDateBox == 1 then HighlightOffset = CurveOffset + 1.25 * DateOffset + 2 * Width.WidthOfDate8
  2163.           else do
  2164.             Select
  2165.               when CalDate < 10 then HighlightOffset = Width.WidthOfDate1 / 2 + Width.WidthOfDate8
  2166.               when CalDate < 20 then HighlightOffset = 1.5 * Width.WidthOfDate1 + Width.WidthOfDate8
  2167.               otherwise HighlightOffset = Width.WidthOfDate1 / 2 + 2 * Width.WidthOfDate8
  2168.             end
  2169.           end
  2170.           HighlightOffset = (1 - Box) * HighlightOffset * (Line * Height.Highlight < Height.Date * TextBase)
  2171.           If Day1Row < 5 then BoxTop = CalTop + Day1Row * BoxHeight
  2172.           else do
  2173.             if DoTopExtraWk ~= 1 then BoxTop = CalTop + 4.5 * BoxHeight
  2174.             else BoxTop = CalTop
  2175.           end
  2176.  
  2177.           if EventType == Image$ then do
  2178.             LeftEdge = Margin.Left + BoxWidth * Day1Column
  2179.  
  2180.             UndoItem = UndoItem + 1
  2181.             Undo.UndoLevel.UndoItem = InsertImage(PE_CurrentImage, LeftEdge + BoxWidth/2, BoxTop + BoxHeight/2, MaxImgWidth * BoxWidth, MaxImgHeight * BoxHeight, 1)
  2182.           end
  2183.           else do
  2184.             LeftEdge = Margin.Left + Day1Column * BoxWidth + CurveOffset + HighlightOffset
  2185.             if event ~= '' then do
  2186.               Textline = 0
  2187.               Text.    = ''
  2188.               Text.Textline = event
  2189.  
  2190.               /* Accomodate user line breaks */
  2191.               do until LineBreak = 0
  2192.                 LineBreak = pos('//', Text.Textline)
  2193.                 if LineBreak > 0 then do
  2194.                   Nextline = Textline + 1
  2195.                   Text.Nextline = substr(Text.Textline, LineBreak + 2)
  2196.                   Text.Textline = left(Text.Textline, LineBreak - 1)
  2197.                   Textline = Nextline
  2198.                 end
  2199.               end
  2200.               Textline = 0
  2201.  
  2202.               /* Fit line(s) into allowable space */
  2203.               do until Text.Nextline == ''
  2204.                 Nextline = Textline + 1
  2205.                 if Box == 1 | Textline == 0 then Indent.Textline = 0
  2206.                 else Indent.Textline = 3 * DateOffset
  2207.                 AllowedWidth = DaySpan * BoxWidth - 2 * CurveOffset - Indent.Textline - HighlightOffset - 2 * DateOffset * Box
  2208.                 AllowedBoxWidth = AllowedWidth + 2 * CurveOffset
  2209.                 if App == 'FW' & length(Text.Textline) > 37 then do
  2210.                   Wordbreak = lastpos(' ', Text.Textline, 37)
  2211.                   Text.Nextline = strip(substr(Text.Textline, Wordbreak)' 'Text.Nextline)
  2212.                   Text.Textline = strip(left(Text.Textline, Wordbreak))
  2213.                 end
  2214.                 ID = PrintText(1, 1, CurrentFont, 'N', TextColor, Width.CurrentFont, Text.Textline)
  2215.                 if App == 'FW' then redraw
  2216.                 TextWidth.Textline = GetWidth(ID)
  2217.                 if App == 'FW' then DELETEOBJECT ID
  2218.                 else if App == 'PGS' then do
  2219.                   SELECTOBJECT OBJECTID ID WINDOW winName
  2220.                   DELETEOBJECT OBJECTID ID WINDOW winName
  2221.                 end
  2222.  
  2223.                 NeededCompression.Textline = min(1, AllowedWidth/TextWidth.Textline)
  2224.                 if (NeededCompression.Textline < MinWidth/100) & (Words(Text.Textline) > 1) then do
  2225.                   /* Move last word to next line */
  2226.                   Wordbreak     = lastpos(' ', Text.Textline)
  2227.                   Text.Nextline = strip(substr(Text.Textline, Wordbreak)' 'Text.Nextline)
  2228.                   Text.Textline = strip(left(Text.Textline, Wordbreak))
  2229.                 end
  2230.                 else if Text.Nextline ~= '' then Textline = Textline + 1
  2231.               end
  2232.               LineCount = Textline
  2233.             end
  2234.  
  2235.             MaxCompression = 1
  2236.             do i = 0 to LineCount
  2237.               MaxCompression = min(MaxCompression, NeededCompression.i)
  2238.             end
  2239.             TextWidth = MaxCompression * Width.CurrentFont
  2240.             if App == 'FW' then TextWidth = min(max(trunc(TextWidth), 4), 255)
  2241.  
  2242.             if Box then do
  2243.               UndoItem = UndoItem + 1
  2244.               Undo.UndoLevel.UndoItem = DrawBox(LeftEdge, BoxTop + Line * Height.Highlight, AllowedBoxWidth, Height.CurrentFont * (LineCount + 1), 'HL', Line.AddEvent, 1, BoxColor, 100)
  2245.             end
  2246.             if event ~= '' then do
  2247.               do i = 0 to LineCount
  2248.                 Text.Top = BoxTop + (Line + i) * Height.Highlight
  2249.                 if Box == 0 then Text.Left = LeftEdge + Indent.i
  2250.                 else Text.Left = LeftEdge + (AllowedBoxWidth - TextWidth.i * MaxCompression) / 2
  2251.                 UndoItem = UndoItem + 1
  2252.                 Undo.UndoLevel.UndoItem = PrintText(Text.Left, Text.Top, CurrentFont, 'N', TextColor, TextWidth, Text.i)
  2253.               end
  2254.             end
  2255.           end
  2256.  
  2257.           Day1 = NextDay1
  2258.           if Day1 > Day2 then leave
  2259.           else if (trunc((Day1 + StartDate - 1) / 7) > 4) & (Day2 > MonthLength.Month) then Day2 = Day1
  2260.         end
  2261.  
  2262.         if Weekly == 1 then do
  2263.           EnteredDay1 = EnteredDay1 + 7
  2264.           EnteredDay2 = EnteredDay2 + 7
  2265.         end
  2266.         else if Weekly == 2 then do
  2267.           EnteredDay1 = EnteredDay1 + 14
  2268.           EnteredDay2 = EnteredDay2 + 14
  2269.         end
  2270.       end
  2271.       else Weekly = 0
  2272.     end
  2273.     if App == 'FW' then redraw
  2274.     else if App == 'PGS' then SELECTOBJECT None WINDOW winName
  2275.   end
  2276.  
  2277.   Undo.UndoLevel.0 = UndoItem
  2278.   call CloseBusy(Req)
  2279.  
  2280.   if App == 'PGS' then do
  2281.     REFRESH ON ALL
  2282.     REFRESHWINDOW WINDOW winName
  2283.     WindowRefreshed = 1
  2284.   end
  2285.  
  2286. return
  2287. /**/
  2288.  
  2289. /***//*** QuoteIt (PROCEDURE) ***/
  2290. QuoteIt: PROCEDURE
  2291.   parse arg String
  2292.  
  2293.   String = strip(String)
  2294.   if (left(String, 1) == '"') & (right(String, 1) == '"') then return String
  2295.   else if (left(String, 1) == "'") & (right(String, 1) == "'") then return String
  2296.   else if pos("'", String) == 0 then return "'"String"'"
  2297.   else return '"'String'"'
  2298.  
  2299.   return
  2300. /**/
  2301.  
  2302. /***//*** ReadBrowserList (RBL) ***/
  2303. ReadBrowserList:
  2304.   parse arg RBL_FileHandle, RBL_GadIDList, RBL_ItemList, RBL_CurrentItem
  2305.  
  2306.   interpret 'RBL_AlreadyOpen = 'RBL_FileHandle
  2307.   if RBL_AlreadyOpen == 0 then do
  2308.     call ToPIPE(RBL_FileHandle, 'open')
  2309.     if (RBL_CurrentItem ~= '') & (MemberID(RBL_CurrentItem, RBL_ItemList) > 0) then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  2310.     interpret RBL_FileHandle '= 1'
  2311.   end
  2312.   else do
  2313.     if (RBL_CurrentItem ~= '') & (MemberID(RBL_CurrentItem, RBL_ItemList) > 0) then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  2314.     call ToPIPE(RBL_FileHandle, 'id 0 s=64')
  2315.   end
  2316.  
  2317.   do while ~eof(RBL_FileHandle)
  2318.     call ToPIPE(RBL_FileHandle, 'continue')
  2319.     RBL_Result = readln(RBL_FileHandle)
  2320.     parse var RBL_Result . . . . RBL_NodeID
  2321.     RBL_NodeID = strip(RBL_NodeID)
  2322.     interpret 'RBL_ListID = 'RBL_GadIDList'.RBL_NodeID'
  2323.     if pos('gadget', RBL_Result) > 0 then leave
  2324.   end
  2325.   call ToPIPE(RBL_FileHandle, 'id 0 s=128')
  2326.   interpret 'RBL_Entry = 'RBL_ItemList'.'RBL_ListID
  2327.   return RBL_Entry
  2328. /**/
  2329.  
  2330. /***//*** ReadFile (PROCEDURE) Subroutine ***/
  2331. ReadFile: PROCEDURE
  2332.   parse arg file
  2333.  
  2334.   if open('Temp', file) then do
  2335.     val = strip(readch('Temp', 65535), 'B', ' '||'0a'x)
  2336.     call close('Temp')
  2337.   end
  2338.   else val = ''
  2339.   return val
  2340. /**/
  2341.  
  2342. /***//*** ReadToEOL (PROCEDURE) Subroutine ***/
  2343. ReadToEOL: PROCEDURE
  2344.   parse arg Start, Var
  2345.  
  2346.   if Start == 0 then return ''
  2347.  
  2348.   EOL = pos('0a'x, Var, Start)
  2349.   if EOL == 0 then EOL = length(Var)
  2350.  
  2351.   return substr(Var, Start, EOL - Start)
  2352. /**/
  2353.  
  2354. /***//*** Round (PROCEDURE) ***/
  2355. Round: PROCEDURE
  2356.   parse arg num, places
  2357.  
  2358.   TruncNum = trunc(num, places)
  2359.  
  2360.   if (num - TruncNum) == 0 then return TruncNum
  2361.  
  2362.   TruncRem = '.'substr(num, pos('.', num) + places + 1)
  2363.   if TruncRem < .5 then return TruncNum
  2364.   else return ((TruncNum * 10**places) + 1)/(10**places)
  2365.  
  2366.   return
  2367. /**/
  2368.  
  2369. /***//*** SaveMsg (SM) Subroutine ***/
  2370. SaveMsg:
  2371.   parse arg SM_Msg
  2372.   if LogOpen ~= 1 then do
  2373.     LogTime = translate(time(), '.', ':')
  2374.     LogOpen = open('FWCLog', ScriptDir'FWCLog'LogTime'.txt', 'W')
  2375.     call writeln('FWCLog', '      Macro: 'strip(substr(sourceline(4), pos(':', sourceline(4)) + 1)))
  2376.     call writeln('FWCLog', 'Application: 'PgmVersion)
  2377.     call writeln('FWCLog', 'Current Dir: 'CurrentDir)
  2378.     call writeln('FWCLog', ' Script Dir: 'ScriptDir)
  2379.     call writeln('FWCLog', '       Host: 'CallHost)
  2380.     call writeln('FWCLog', '   Calendar: 'Month.Month' 'Year||'0a'x)
  2381.     call close('FWCLog')
  2382.   end
  2383.  
  2384.   LogOpen = open('FWCLog', ScriptDir'FWCLog'LogTime'.txt', 'A')
  2385.     call writeln('FWCLog', SM_Msg)
  2386.   call close('FWCLog')
  2387.  
  2388.   return
  2389. /**/
  2390.  
  2391. /***//*** Syntax () Subroutine ***/
  2392. Syntax:
  2393.   signal off syntax
  2394.  
  2395.   ErrorLine  = SIGL
  2396.   SourceLine = strip(SourceLine(ErrorLine))
  2397.  
  2398.   call AddMsg('E', 'Error 'RC' ('errortext(RC)')')
  2399.   call AddMsg('E', 'Line 'ErrorLine': 'SourceLine)
  2400.   call AddMsg('E', ParseVariables(SourceLine))
  2401.  
  2402.   call Cleanup
  2403.   exit
  2404. /**/
  2405.  
  2406. /***//*** ToPIPE (TP) ***/
  2407. ToPIPE:
  2408.   parse arg PipeName, TP_CMD
  2409.  
  2410.   call writeln(PipeName,' 'TP_CMD)
  2411.   TP_Response=readln(PipeName)
  2412.  
  2413.   parse var TP_Response TP_Response1 TP_Response2 .
  2414.  
  2415.   if TP_Response1 == 'ok' then return(TP_Response2)
  2416.   if TP_Response == '' then TP_Response = 'Blank line'
  2417.   call AddMsg('E', 'Line : 'SIGL)
  2418.   call AddMsg('E', PipeName' error: 'TP_Response)
  2419.   call AddMsg('E', 'Returned from: 'TP_CMD)
  2420.   call Cleanup
  2421. /**/
  2422.  
  2423. /***//*** TranslationStrings () ***/
  2424. TranslationStrings:
  2425. Sunday$    = 'Sunday'
  2426. Monday$    = 'Monday'
  2427. Tuesday$   = 'Tuesday'
  2428. Wednesday$ = 'Wednesday'
  2429. Thursday$  = 'Thursday'
  2430. Friday$    = 'Friday'
  2431. Saturday$  = 'Saturday'
  2432.  
  2433. January$   = 'January'
  2434. February$  = 'February'
  2435. March$     = 'March'
  2436. April$     = 'April'
  2437. May$       = 'May'
  2438. June$      = 'June'
  2439. July$      = 'July'
  2440. August$    = 'August'
  2441. September$ = 'September'
  2442. October$   = 'October'
  2443. November$  = 'November'
  2444. December$  = 'December'
  2445.  
  2446. AddEvent$       = 'Add Event'
  2447. AddIC$          = '+IC'
  2448. All$            = 'All'
  2449. BiOrWeekly$     = '(Bi)Weekly'
  2450. Biweekly$       = 'Biweekly'
  2451. Bottom$         = 'Bottom'
  2452. BoxColor$       = 'Box'
  2453. BoxDates$       = 'Box Dates'
  2454. Boxed$          = '_Boxed'
  2455. Calendar$       = 'Calendar'
  2456. Calendars$      = 'Calendars'
  2457. Cancel$         = '_Cancel'
  2458. CantFind$       = "can't be found"
  2459. Center$         = 'Center'
  2460. Clear$          = 'Clear'
  2461. Color$          = 'Color'
  2462. Colors$         = 'Colors'
  2463. Comment$        = 'Comment'
  2464. Critical$       = 'Critical error'
  2465. DailyColors$    = 'Use daily colors'
  2466. DeleteEvent$    = 'Delete Event'
  2467. Done$           = 'Done'
  2468. Easter$         = 'Easter'
  2469. End$            = 'End'
  2470. EnterEvent$     = 'You must enter an event...'
  2471. EnterEventInfo$ = 'Enter event information'
  2472. EnterNewIC$     = 'Enter new ImageClass'
  2473. EnterStartdate$ = 'You must enter a start date...'
  2474. Even$           = 'Even'
  2475. Event$          = 'Event'
  2476. Extended$       = 'Extended'
  2477. File$           = 'File'
  2478. First$          = 'First'
  2479. Fixed$          = 'Fixed'
  2480. Floating$       = 'Floating'
  2481. Font$           = 'Font'
  2482. Fonts$          = 'Fonts'
  2483. ForDetails$     = 'for details'
  2484. ForwardContent$ = 'Forward contents of output to'
  2485. ForwardLog$     = 'Forward log file to'
  2486. Fourth$         = 'Fourth'
  2487. Frequency$      = 'Frequency'
  2488. GeneratingM$    = 'Generating %s %s calendar'
  2489. GeneratingY$    = 'Generating %s calendar'
  2490. Go$             = 'Go'
  2491. Header$         = '%s %s'
  2492. HighlightEd$    = 'Highlight Editor'
  2493. Highlights$     = 'Highlights'
  2494. History$        = 'History'
  2495. Holiday$        = 'Holiday'
  2496. Image$          = 'Image'
  2497. Images$         = 'Images'
  2498. Julian$         = 'Julian'
  2499. JulJulLeft$     = 'Jul/Jul Left'
  2500. JulLeft$        = 'Jul Left'
  2501. Last$           = 'Last'
  2502. Left$           = 'Left'
  2503. Line$           = '_Line'
  2504. Load$           = '_Load'
  2505. MatchColors$    = 'Date Color = Highlight Color'
  2506. MiniCals$       = 'MiniCals'
  2507. MiscVar$        = 'Miscellaneous Variables'
  2508. MultiMonth$     = 'Multi-Month'
  2509. MustUse$        = 'You must use the gadget to'||'0a'x||'the right for this value.'
  2510. NextDay$        = 'Next day'
  2511. Noncritical$    = 'Noncritical warning'
  2512. None$           = 'None'
  2513. NotClear$       = '<'Clear$'> can only be used for "Background." variables...'
  2514. Note$           = 'Notes'
  2515. NoteBox$        = 'Note box'
  2516. Notice$         = 'notice'
  2517. Odd$            = 'Odd'
  2518. OK$             = '_OK'
  2519. OK2$            = 'OK'
  2520. Once$           = 'Once'
  2521. Options$        = 'Options'
  2522. OptLayout$      = 'Options & Layout'
  2523. OrientMarg$     = 'Orientation & Margins'
  2524. Phases$         = 'Phases'
  2525. PleaseWait$     = 'please wait'
  2526. PrepReq$        = 'Preparing requester'
  2527. PreviousDay$    = 'Prev day'
  2528. ProcessEvents$  = 'Processing events'
  2529. Random$         = 'Random'
  2530. Reset$          = '_Reset'
  2531. Right$          = 'Right'
  2532. RiseSet$        = 'Rise/Set'
  2533. SaveAs$         = '_Save as'
  2534. Second$         = 'Second'
  2535. See$            = 'see'
  2536. SeeOutput$      = 'see the output above for details'
  2537. SeeShell$       = 'see the shell output for details'
  2538. SelectApp$      = 'Select application'
  2539. SelectFile$     = 'Select data file'
  2540. SelectFont$     = 'Select font'
  2541. SelectImage$    = 'Select image'
  2542. SelectPrefs$    = 'Select name for prefs file'
  2543. SingleMonth$    = 'Single Month'
  2544. Start$          = 'Start'
  2545. SubHeader$      = ''
  2546. Sunrise$        = 'Sunrise'
  2547. Sunset$         = 'Sunset'
  2548. Tall$           = 'Tall'
  2549. TextColor$      = 'Text'
  2550. Third$          = 'Third'
  2551. Top$            = 'Top'
  2552. TopLong$        = 'Extra week at top'
  2553. Type$           = 'Type'
  2554. Unable$         = 'if you are unable to resolve the problem.'
  2555. Undo$           = 'Undo'
  2556. VarGUITitle$    = 'Set desired variables'
  2557. Variables$      = 'Variables'
  2558. View$           = 'View'
  2559. Weekend$        = 'Weekend'
  2560. Weekly$         = 'Weekly'
  2561. WeekNumber$     = 'Week Number'
  2562. WeekType$       = 'Week Type'
  2563. WholeYear$      = 'Whole Year'
  2564. Wide$           = 'Wide'
  2565.  
  2566. Help$                       = 'Help message'
  2567. Help$.ClickTabHelp          = 'Different tabs display*ndifferent variables'
  2568. Help$.MiniCalsGadHelp       = 'Include mini-calendars showing*nthe previous & next months'
  2569. Help$.HighlightsGadHelp     = 'Include highlights on*nthe generated calendar'
  2570. Help$.ImagesGadHelp         = 'Include images on*nthe generated calendar'
  2571. Help$.BoxDatesGadHelp       = 'Surround day numbers*nwith boxes'
  2572. Help$.ExtendedGadHelp       = 'Include days from the previous*nand next months on the*ngenerated calendar'
  2573. Help$.TopLongGadHelp        = 'Include days from the sixth week*nat the top of the calendar'
  2574. Help$.NoteBoxGadHelp        = 'Include an area to write notes*nwhere no dates are printed'
  2575. Help$.TopMargGadHelp        = "Set calendar's top margin*nRemember to <RETURN>"
  2576. Help$.LeftMargGadHelp       = "Set calendar's left margin*nRemember to <RETURN>"
  2577. Help$.OrientationGadHelp    = "Set calendar's orientation"
  2578. Help$.RightMargGadHelp      = "Set calendar's right margin*nRemember to <RETURN>"
  2579. Help$.BottomMargGadHelp     = "Set calendar's bottom margin*nRemember to <RETURN>"
  2580. Help$.FontVarGadHelp        = 'Select the font variable to set'
  2581. Help$.FontValGadHelp        = 'Displays the choosen font value'
  2582. Help$.ChooseFontGadHelp     = 'Select the desired font'
  2583. Help$.ColorVarGadHelp       = 'Select the color variable to set'
  2584. Help$.CycleColorVarGadHelp  = 'Cycle through the color variables*nShift to reverse cycle'
  2585. Help$.ColorValGadHelp       = 'Select the desired color'
  2586. Help$.MatchColorsGadHelp    = 'Use the highlight text color*nfor the date/date box'
  2587. Help$.DailyColorsGadHelp    = 'Use the Color.(Weekday) colors*nfor the date/date box'
  2588. Help$.HighlightEditGadHelp  = 'Bring up the*nHighlight Editor'
  2589. Help$.MiscVarGadHelp        = 'Select the desired*nmiscellaneous variable'
  2590. Help$.CycleMiscVarGadHelp   = 'Cycle through the miscellaneous variables*nShift to reverse cycle'
  2591. Help$.MiscValGadHelp        = 'Enter the desired variable value'
  2592. Help$.ChooseValGadHelp      = 'Used only for selecting files/paths'
  2593. Help$.AddImageClassGadHelp  = 'Add an ImageClass variable'
  2594. Help$.Extra3Help            = "Select extra to be printed*nin calendar's top-center"
  2595. Help$.Extra4Help            = "Select extra to be printed*nin calendar's top-right"
  2596. Help$.Extra0Help            = "Select extra to be printed*nin calendar's bottom-left"
  2597. Help$.Extra1Help            = "Select extra to be printed*nin calendar's bottom-center"
  2598. Help$.Extra2Help            = "Select extra to be printed*nin calendar's bottom-right"
  2599. Help$.CalendarTypeGadHelp   = 'Select calendar type'
  2600. Help$.EndMonthGadHelp       = 'Select desired end month'
  2601. Help$.StartMonthGadHelp     = 'Select desired start month'
  2602. Help$.MonthGadHelp          = 'Select desired month'
  2603. Help$.YearGadHelp           = 'Select or enter desired year'
  2604. Help$.GoGadHelp             = 'Begin generation of calendar'
  2605. Help$.ResetGadHelp          = 'Reset all variables to defaults'
  2606. Help$.LoadGadHelp           = 'Load a new preference file'
  2607. Help$.SaveAsGadHelp         = 'Save current settings to*na new preference file'
  2608. Help$.CancelGadHelp         = 'Cancel FWCalendar'
  2609. Help$.EH_EventGadHelp       = 'Enter the Highlight as it*nwill show up on calendar'
  2610. Help$.EH_ChooseEventGadHelp = 'Select Image file to be printed on calendar'
  2611. Help$.EH_ListEventGadHelp   = 'List all Highlights*nfor current month'
  2612. Help$.EH_CycleEventGadHelp  = 'Cycle through all Highlights*nfor current month'
  2613. Help$.EH_CommentGadHelp     = 'Enter optional comment'
  2614. Help$.EH_MonthGadHelp       = 'Select month to work with'
  2615. Help$.ExtraDHelp            = 'Select the date on*nwhich the Highlight falls'
  2616. Help$.LD                    = 'Indicates the Highlight always falls*non the last day of the month'
  2617. Help$.EH_ColorGadHelp       = 'Select color to be*nused for the Highlight'
  2618. Help$.EH_HLTypeGadHelp      = 'Select the Highlight type'
  2619. Help$.EH_WeekNumberGadHelp  = 'Select which week a floating*nHighlight occurs in'
  2620. Help$.EH_WeekTypeGadHelp    = 'Select frequency of weekly Highlights'
  2621. Help$.EH_WeekendGadHelp     = 'Determine whether or not the*nHighlight can fall on a weekend'
  2622. Help$.EH_HolidayGadHelp     = 'Treat the Highlight as a holiday'
  2623. Help$.EH_EasterGadHelp      = 'The number of days before or*nafter Easter for the Highlight'
  2624. Help$.EH_AddEventGadHelp    = 'Add a new Highlight'
  2625. Help$.EH_DeleteEventGadHelp = 'Delete the currently*ndisplayed Highlight'
  2626. Help$.EH_DoneGadHelp        = 'Save all changes to Highlights'
  2627. Help$.GE_EventTypeGadHelp   = 'Select to enter Event or*nuse an Event file'
  2628. Help$.GE_EventGadHelp       = 'Enter Event or display Event file'
  2629. Help$.GE_FontNameGadHelp    = 'Display font to be used'
  2630. Help$.GE_FontSizeGadHelp    = 'Enter font size to use'
  2631. Help$.GE_ChooseFontGadHelp  = 'Select font to be used'
  2632. Help$.GE_ResetGadHelp       = 'Reset font and font size'
  2633. Help$.GadIDHelp             = 'Enter Event start and end dates'
  2634. Help$.GE_StartGadHelp       = 'Display Event start date'
  2635. Help$.GE_EndGadHelp         = 'Display Event end date'
  2636. Help$.GE_TextColorGadHelp   = 'Select color to be*nused for Event text'
  2637. Help$.GE_LineGadHelp        = 'Select row on which*nEvent will be printed'
  2638. Help$.GE_BoxedGadHelp       = 'Surround Event with a box'
  2639. Help$.GE_BoxColorGadHelp    = 'Select color for box*nsurrounding Event'
  2640. Help$.GE_FrequencyGadHelp   = 'Select frequency of Event'
  2641. Help$.GE_OKGadHelp          = 'Use entered data to add*nEvent to calendar'
  2642. Help$.GE_CancelGadHelp      = 'Cancel FWCAddEvent'
  2643.  
  2644. return 0
  2645. /**/
  2646.  
  2647. /***//*** VIO Routines () Subroutine ***/
  2648. /***//** OpenV() **/
  2649. OpenV:
  2650.   parse arg VIO_Variable
  2651.  
  2652.   if Open.VIO_Variable ~= 1 then do
  2653.     Open.VIO_Variable = 1
  2654.     Pointer.VIO_Variable = 1
  2655.     EOF.VIO_Variable = 0
  2656.     return 1
  2657.   end
  2658.   else return 0
  2659. /**/
  2660.  
  2661. /***//** CloseV() **/
  2662. CloseV:
  2663.   parse arg VIO_Variable
  2664.  
  2665.   If Open.VIO_Variable == 0 then return 0
  2666.   Open.VIO_Variable = 0
  2667.   return 1
  2668. /**/
  2669.  
  2670. /***//** SeekV() **/
  2671. SeekV:
  2672.   parse arg VIO_Variable, VIO_Offset, VIO_Anchor
  2673.  
  2674.   if Open.VIO_Variable == 1 then do
  2675.     VIO_Anchor = upper(left(VIO_Anchor, 1))
  2676.  
  2677.     VIO_Value = Value(VIO_Variable)
  2678.     select
  2679.       when VIO_Anchor == 'B' then Pointer.VIO_Variable = VIO_Offset
  2680.       when VIO_Anchor == 'E' then Pointer.VIO_Variable = length(VIO_Value) + VIO_Offset
  2681.       otherwise Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Offset
  2682.     end
  2683.  
  2684.     if Pointer.VIO_Variable > length(VIO_Value) then Pointer.VIO_Variable = length(VIO_Value) + 1
  2685.     return Pointer.VIO_Variable
  2686.   end
  2687.   else return 0
  2688. /**/
  2689.  
  2690. /***//** ReadVCh() **/
  2691. ReadVCh:
  2692.   parse arg VIO_Variable, VIO_Length
  2693.  
  2694.   if VIO_Length == '' then VIO_Length = 1
  2695.  
  2696.   if Open.VIO_Variable == 1 then do
  2697.     if EOF.VIO_Variable == 0 then do
  2698.       VIO_Value = Value(VIO_Variable)
  2699.       VIO_Ret = substr(VIO_Value, Pointer.VIO_Variable, VIO_Length)
  2700.       Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Length
  2701.       if Pointer.VIO_Variable > length(VIO_Value) then EOF.VIO_Variable = 1
  2702.       else EOF.VIO_Variable = 0
  2703.     end
  2704.     else VIO_Ret = ''
  2705.   end
  2706.   else VIO_Ret = ''
  2707.  
  2708.   return VIO_Ret
  2709. /**/
  2710.  
  2711. /***//** ReadVLn(RV) **/
  2712. ReadVLn:
  2713.   parse arg VIO_Variable, VIO_Count, VIO_SepChar
  2714.  
  2715.   if VIO_Count == '' then VIO_Count = 1
  2716.   if VIO_SepChar == '' then VIO_SepChar = '0a'x
  2717.  
  2718.   if Open.VIO_Variable == 1 then do
  2719.     VIO_Value = Value(VIO_Variable)
  2720.     VIO_Ret   = ''
  2721.     do VIO_i = 1 to VIO_Count
  2722.       VIO_LF = pos('0a'x, VIO_Value, Pointer.VIO_Variable)
  2723.       if VIO_LF > 0 then do
  2724.         VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable, VIO_LF - Pointer.VIO_Variable)
  2725.         Pointer.VIO_Variable = VIO_LF + 1
  2726.         if VIO_LF = length(VIO_Value) then EOF.VIO_Variable = 1
  2727.         else EOF.VIO_Variable = 0
  2728.       end
  2729.       else do
  2730.         if Pointer.VIO_Variable < length(VIO_Value) then do
  2731.           VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable)
  2732.           Pointer.VIO_Variable = length(VIO_Value) + 1
  2733.           EOF.VIO_Variable = 1
  2734.         end
  2735.       end
  2736.       if EOF.VIO_Variable == 1 then leave
  2737.       if VIO_i ~= VIO_Count then VIO_Ret = VIO_Ret''VIO_SepChar
  2738.     end
  2739.   end
  2740.   else VIO_Ret = ''
  2741.  
  2742.   return VIO_Ret
  2743. /**/
  2744.  
  2745. /***//** WriteVCh() **/
  2746. WriteVCh:
  2747.   parse arg VIO_Variable, VIO_String, VIO_Option
  2748.  
  2749.   VIO_Value  = Value(VIO_Variable)
  2750.   VIO_Option = upper(left(VIO_Option, 1))
  2751.   VIO_Length = length(VIO_Value)
  2752.   if VIO_Option == 'C' then do
  2753.     VIO_Value = Insert(VIO_String, VIO_Value, Pointer.VIO_Variable - 1)
  2754.     Pointer.VIO_Variable = Pointer.VIO_Variable + length(VIO_String)
  2755.   end
  2756.   else if VIO_Option == 'B' then do
  2757.     VIO_Value = VIO_String''VIO_Value
  2758.     Pointer.VIO_Variable = length(VIO_String) + 1
  2759.   end
  2760.   else do
  2761.     VIO_Value = VIO_Value''VIO_String
  2762.     Pointer.VIO_Variable = length(VIO_Value)
  2763.   end
  2764.   interpret VIO_Variable'= VIO_Value'
  2765.   if length(VIO_Value) = VIO_Length + length(VIO_String) then VIO_Ret = length(VIO_String)
  2766.   else VIO_Ret = 0
  2767.  
  2768.   return VIO_Ret
  2769. /**/
  2770.  
  2771. /***//** WriteVLn() **/
  2772. WriteVLn:
  2773.   parse arg VIO_Variable, VIO_String, VIO_Option
  2774.  
  2775.   return WriteVCh(VIO_Variable, VIO_String||'0a'x, VIO_Option)
  2776. /**/
  2777.  
  2778. /***//** EOFV() **/
  2779. EOFV:
  2780.   parse arg VIO_Variable
  2781.  
  2782.   if Open.VIO_Variable == 1 then return EOF.VIO_Variable
  2783.   else return 1
  2784. /**/
  2785. /**/
  2786.  
  2787. /***//*** WriteFile (PROCEDURE) Subroutine ***/
  2788. WriteFile: PROCEDURE
  2789.   parse arg file, var, which
  2790.  
  2791.   if open('Temp', file, 'W') then do
  2792.     success = writech('Temp', var)
  2793.     call close('Temp')
  2794.   end
  2795.   if (upper(which) == 'B') & (upper(left(file, 4)) == 'ENV:') then call WriteFile('ENVARC:'substr(file, 5), var)
  2796.  
  2797.   return success
  2798. /**/
  2799.  
  2800. /***//*** SetVariables Subroutine ***/
  2801. SetVariables:
  2802. /***//**** Initialize Variables ****/
  2803.   Date            = 0
  2804.   esc             = "1B"x
  2805.   QuoteMark       = d2c(34)
  2806.   EventFile       = ''
  2807.   FontKnown.      = ''
  2808.   FSize.          = 10
  2809.   HighestFont     = 5
  2810.   Highlight       = 5
  2811.   ImageType.      = ''
  2812.   PatVar          = '#?.data'
  2813.   PrefsFile       = ''
  2814.   Req             = 0
  2815.   Storage         = 'RAM:FWC/'
  2816.   Width.          = 100
  2817.   UndoLevel       = 0
  2818.   ColorW          = 80
  2819.   ColorH          = 10
  2820.   PE_ImageCount   = 0
  2821.  
  2822.   if App == 'FW' then DefaultFont = "SoftSans"
  2823.   else if App == 'PGS' then DefaultFont = 'PageStream-Normal'
  2824.  
  2825.   PGSRecognizedFormats = '|PICT|TIFF|IFFILBM|GIF|BMP|IFFDR2D|IFFILUS|JPEG|MACPAINT|PRODRAW|PCX|ILLUSTRATOREPS|FREEHANDEPS|ARTEXPRESSIONEPS|EPS|'
  2826.  
  2827.   PGSFilter.     = ''
  2828.   PGSFilter.ILBM = 'IFFILBM'
  2829.   PGSFilter.JFIF = 'JPEG'
  2830.   PGSFilter.POST = 'IllustratorEPS'
  2831.  
  2832.   GfxCmd.FWCalendar       = ''
  2833.   GfxTemplate.FWCalendar  = 'ImgDT ImgWidth ImgHeight .'
  2834.  
  2835.   GfxCmd.Visage           = '%s info'
  2836.   GfxTemplate.Visage      = '. "0a"x . ImgDT ImgWidth "x" ImgHeight "x" .'
  2837.  
  2838.   GfxCmd.ImageDTInfo      = '%s'
  2839.   GfxTemplate.ImageDTInfo = 'ImgDT "-" ImgWidth "x" ImgHeight "x" .'
  2840.  
  2841.   GfxCmd.PicSize          = '%s "%t %w %h"'
  2842.   GfxTemplate.PicSize     = 'ImgDT ImgWidth ImgHeight "0a"x'
  2843.  
  2844.   D.0 = 'Sunday'
  2845.   D.1 = 'Monday'
  2846.   D.2 = 'Tuesday'
  2847.   D.3 = 'Wednesday'
  2848.   D.4 = 'Thursday'
  2849.   D.5 = 'Friday'
  2850.   D.6 = 'Saturday'
  2851.  
  2852.   EnglishSunday$    = 'Sunday'
  2853.   EnglishMonday$    = 'Monday'
  2854.   EnglishTuesday$   = 'Tuesday'
  2855.   EnglishWednesday$ = 'Wednesday'
  2856.   EnglishThursday$  = 'Thursday'
  2857.   EnglishFriday$    = 'Friday'
  2858.   EnglishSaturday$  = 'Saturday'
  2859.  
  2860.   MonthLength.1    = 31
  2861.   MonthLength.2    = 28
  2862.   MonthLength.3    = 31
  2863.   MonthLength.4    = 30
  2864.   MonthLength.5    = 31
  2865.   MonthLength.6    = 30
  2866.   MonthLength.7    = 31
  2867.   MonthLength.8    = 31
  2868.   MonthLength.9    = 30
  2869.   MonthLength.10   = 31
  2870.   MonthLength.11   = 30
  2871.   MonthLength.12   = 31
  2872.  
  2873.   Month.1  = January$
  2874.   Month.2  = February$
  2875.   Month.3  = March$
  2876.   Month.4  = April$
  2877.   Month.5  = May$
  2878.   Month.6  = June$
  2879.   Month.7  = July$
  2880.   Month.8  = August$
  2881.   Month.9  = September$
  2882.   Month.10 = October$
  2883.   Month.11 = November$
  2884.   Month.12 = December$
  2885. /**/
  2886.  
  2887. /***//**** Read default variables ****/
  2888.   call open('Temp', FullCallPath)
  2889.     call seek('Temp', -5000, 'E')
  2890.     Chunk = readch('Temp', 65535)
  2891.     EndPos = pos('VarList:'||'0a'x, Chunk)
  2892.     if EndPos == 0 then do
  2893.       call AddMsg('E', 'Unable to locate default variables.')
  2894.       call CleanUp
  2895.     end
  2896.     RD_VariableFile = substr(Chunk, EndPos + 9)
  2897.   call close('Temp')
  2898.   interpret left(RD_VariableFile, pos('return', RD_VariableFile) - 1)
  2899. /**/
  2900.  
  2901. /***//**** Determine prefs file from calendar ****/
  2902.   if App == 'FW' then do
  2903.     FIRSTOBJECT; TempDateID = result
  2904.     do forever
  2905.       if TempDateID == 0 then do
  2906.         call AddMsg('E', 'Unable to find FWC date string.')
  2907.         call AddMsg('E', 'Make sure a Monthly calendar created by FWCalendar.rexx is currently loaded.')
  2908.         call Cleanup
  2909.       end
  2910.       GETOBJECTTYPE TempDateID; ObjectType = result
  2911.       if ObjectType == 7 then do
  2912.         GETTEXTBLOCKTEXT TempDateID; TempDate = result
  2913.         if (left(TempDate, 3) == 'FWC') & (datatype(substr(TempDate, 4, 8)) == 'NUM') then leave
  2914.       end
  2915.       NEXTOBJECT TempDateID; TempDateID = result
  2916.     end
  2917.     do while right(TempDate, 1) == '|'
  2918.       StartObj = pos('|', TempDate)
  2919.       NextObj = strip(substr(TempDate, StartObj), 'B', '|')
  2920.       if NextObj == TempDateID then NextObj = NextObj - 1
  2921.       GETTEXTBLOCKTEXT NextObj; NextPart = result
  2922.       TempDate = left(TempDate, StartObj - 1)''NextPart
  2923.     end
  2924.   end
  2925.   else if App = 'PGS' then do
  2926.     CURRENTWINDOW; winName = '"'RESULT'"'
  2927.     SELECTTEXT at 0 0 WINDOW winName
  2928.     SELECTTEXT ALL WINDOW winName
  2929.     EXPORTTEXT AMIGA FILE "PIPE:FWC" FILTER "ASCII" STATUS FORCE
  2930.     TempDate = ReadFile("PIPE:FWC")
  2931.     SENDTOBACK WINDOW winName
  2932.     if (left(TempDate, 3) ~= 'FWC') | (datatype(substr(TempDate, 4, 8)) ~= 'NUM') then do
  2933.       call AddMsg('E', 'Unable to find FWC date string.')
  2934.       call AddMsg('E', 'Make sure a Monthly calendar created by FWCalendar.rexx is currently loaded.')
  2935.       call Cleanup
  2936.     end
  2937.     else do
  2938.       do while right(TempDate, 1) == '|'
  2939.         StartPointer = pos('|', TempDate)
  2940.         SELECTTEXT at 0 0 WINDOW winName
  2941.         SELECTTEXT ALL WINDOW winName
  2942.         EXPORTTEXT AMIGA FILE "PIPE:FWC" FILTER "ASCII" STATUS FORCE
  2943.         TempDate = left(TempDate, StartPointer - 1)''readfile("PIPE:FWC")
  2944.         SENDTOBACK WINDOW winName
  2945.       end
  2946.     end
  2947.   end
  2948.   if pos('~', TempDate) == 12 then do
  2949.     FWCVer = substr(TempDate, pos('~', TempDate) + 1)
  2950.     StartPrefs = pos('~', FWCVer)
  2951.     PrefsFile = substr(FWCVer, StartPrefs + 1)
  2952.     FWCVer = left(FWCVer, StartPrefs - 1)
  2953.     TempDate = substr(TempDate, 4, 8)
  2954.   end
  2955.   else FWCVer = 0
  2956.  
  2957.   if FWCVer < MinFWCVer then do
  2958.     call AddMsg('E', 'This version of FWCAddEvent will only work with calendars')
  2959.     call AddMsg('E', 'created with FWCalendar version 'MinFWCVer' or later.')
  2960.     if FWCVer > 0 then call AddMsg('E', 'This calendar was created with FWCalendar v'FWCVer'.')
  2961.     else call AddMsg('E', 'This calendar was created with FWCalendar pre-v4.22.')
  2962.     call Cleanup
  2963.   end
  2964. /**/
  2965.  
  2966. /***//**** Get application colors ****/
  2967.   if App == 'FW' then do
  2968.     FWPrefs = ReadFile(CurrentDir'FWFiles/FW.Prefs')
  2969.     ColorTable = pos('SWCL', FWPrefs) + 12
  2970.     EndTable = pos('STUP', FWPrefs)
  2971.     ColorCount = 0
  2972.     Do CTPos = ColorTable to EndTable by 20
  2973.       ColorRegister.ColorCount = c2x(substr(FWPrefs, CTPos - 3, 3))
  2974.       ColorList.ColorCount = strip(substr(FWPrefs, CTPos, 16), 'B', '00'x)
  2975.       if ColorRegister.ColorCount = '000000' then Black$ = ColorList.ColorCount
  2976.       if ColorRegister.ColorCount = 'FFFFFF' then White$ = ColorList.ColorCount
  2977.       ColorCount = ColorCount + 1
  2978.     end
  2979.     ColorList.ColorCount = '<'Clear$'>'
  2980.     ColorCount = ColorCount + 1
  2981.     ColorList.COUNT = ColorCount
  2982.     if symbol('Black$') == 'LIT' then do
  2983.       call AddMsg('W', "The color black can't be found; "ColorList.0" used instead.")
  2984.       Black$ = ColorList.0
  2985.     end
  2986.     if symbol('White$') == 'LIT' then do
  2987.       call AddMsg('W', "The color white can't be found; "ColorList.1" used instead.")
  2988.       White$ = ColorList.1
  2989.     end
  2990.   end
  2991.   else if App == 'PGS' then do
  2992.     GETFONTLIST FontList
  2993.     FontList.COUNT = result
  2994.  
  2995.     PGSColors = ReadFile(CurrentDir''word(PgmVersion, 1)'.colors')
  2996.     ColorCount = 0
  2997.     StartTag = pos('TG'||'00'x, PGSColors)
  2998.     do while StartTag ~= 0
  2999.       Color = substr(PGSColors, StartTag + 10, c2d(substr(PGSColors, StartTag + 9, 1)))
  3000.       AccentMarker = pos(d2c(129), Color)
  3001.       do while AccentMarker > 0
  3002.         Color = overlay(d2c(c2d(substr(Color, AccentMarker + 1, 1)) + 128), delstr(Color, AccentMarker, 1), AccentMarker)
  3003.         AccentMarker = pos(d2c(129), Color)
  3004.       end
  3005.       ColorList.ColorCount = Color
  3006.       ColorCount = ColorCount + 1
  3007.       StartTag = pos('TG'||'00'x, PGSColors, StartTag + 10)
  3008.     end
  3009.     ColorList.ColorCount = '<'Clear$'>'
  3010.     ColorCount = ColorCount + 1
  3011.     ColorList.COUNT = ColorCount
  3012.     White$ = ColorList.0
  3013.     Black$ = ColorList.1
  3014.   end
  3015.   TextColorList.Count = ColorList.COUNT - 1
  3016.  
  3017.   do i = 0 to TextColorList.Count - 1
  3018.     TextColorList.i = ColorList.i
  3019.   end
  3020.  
  3021.   Color.          = Black$
  3022.   Line.           = Black$
  3023.   Background.     = White$
  3024. /**/
  3025.  
  3026.   GSI_Data = ReadFile(PrefsFile)
  3027.   if GSI_Data ~= '' then do
  3028.     GSI_UpperData = upper(GSI_Data)
  3029.     interpret ReadToEOL(pos('STORAGE', GSI_UpperData), GSI_UpperData)
  3030.     interpret ReadToEOL(pos('FORCEBGUI', GSI_UpperData), GSI_UpperData)
  3031.     interpret ReadToEOL(pos('HOSTSCREEN', GSI_UpperData), GSI_UpperData)
  3032.  
  3033.     if ForceBGUI == 1 then call AddBGUI
  3034.     if HostScreen ~= '' then AppScreen = HostScreen
  3035.   end
  3036.   address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  3037.  
  3038.   if (PrefsFile ~= 'Default') & (exists(PrefsFile)) then do
  3039.     UserFile = ReadFile(PrefsFile)
  3040.     if UserFile ~= '' then do
  3041.       call openv('UserFile')
  3042.         do until eofv('UserFile')
  3043.           CD_VarLine = strip(ReadvLn('UserFile'))
  3044.           if left(CD_VarLine, 15) == '/* End Pass One' then leave
  3045.           if upper(left(CD_VarLine, 11)) == 'IMAGECLASS.' then iterate
  3046.           interpret CD_VarLine
  3047.         end
  3048.       call closev('UserFile')
  3049.     end
  3050.   end
  3051.   drop Orientation
  3052.  
  3053.   Type.0    = Event$
  3054.   Type.1    = Image$
  3055.   Type.2    = File$
  3056.   FSize.4pt = 4
  3057.  
  3058.   CalendarBorder = CalendarBorder / 100
  3059.   CalendarShadow = CalendarShadow / 100
  3060.   CornerRadius   = CornerRadius / 100
  3061.   DateOffset     = DateOffset / 100
  3062.   MaxImgHeight   = MaxImgHeight / 100
  3063.   MaxImgWidth    = MaxImgWidth / 100
  3064.   StretchDateH   = StretchDateH / 100
  3065.   StretchDateW   = StretchDateW / 100
  3066.   TextAdj        = TextAdj / 100
  3067.   TTextArea      = TTextArea / 100
  3068.   WTextArea      = WTextArea / 100
  3069.  
  3070.   do i = 0 to 6
  3071.     val = i - StartWeek
  3072.     if val < 0 then val = 7 + val
  3073.     interpret 'Day.'D.i '=' val
  3074.     interpret 'Day.val = English'D.i'$'
  3075.     interpret 'TransDay.val = 'D.i'$'
  3076.   end
  3077.  
  3078.   if Symbol('EndWeek') == 'LIT' then EndWeek = -1
  3079.   if EndWeek < 0 then EndWeek = StartWeek - 1
  3080.   if EndWeek < 0 then EndWeek = 6
  3081.   if EndWeek < StartWeek then WeekdayCount = EndWeek + 7 - StartWeek
  3082.   else WeekdayCount = EndWeek - StartWeek
  3083.  
  3084.   if App == 'FW' then do
  3085.     TextBase = TextAdj
  3086.     do i = 0 to 5 by 5
  3087.       if Font.i == NameOnly(Font.i) then Font.i = CurrentDir'FWFonts/SWOLFonts/'Font.i
  3088.       if ~exists(Font.i) then do
  3089.         call AddMsg('W', NameOnly(Font.i)" can't be found; "DefaultFont" used instead.")
  3090.         Font.i = DefaultFont
  3091.       end
  3092.     end
  3093.     GETPAGESETUP ORIENT; FWC_Orientation = result
  3094.     if FWC_Orientation == 'Wide' then TextArea = WTextArea
  3095.     else TextArea = TTextArea
  3096.  
  3097.     GETDISPLAYPREFS Measure; UserPrefs = 'DISPLAYPREFS Measure 'result
  3098.     DISPLAYPREFS Measure Inches
  3099.     GETSECTIONSETUP Top Bottom Inside Outside
  3100.     parse var result Margin.Top Margin.Bottom Margin.Left Margin.Right
  3101.  
  3102.     GETPAGESETUP Width Height
  3103.     parse var result FullWidth FullHeight
  3104.  
  3105.     TextBlockPrefs TEXTFLOW None
  3106.   end
  3107.   else if App = 'PGS' then do
  3108.     TextBase = 1
  3109.     GETFONTLIST FontNames
  3110.     FontNames.COUNT = result
  3111.     do i = 0 to 5 by 5
  3112.       do j = 0 to FontNames.COUNT - 1
  3113.         if upper(Font.i) == upper(FontNames.j) then leave
  3114.       end
  3115.       if j == FontNames.COUNT then do
  3116.         call AddMsg('W', Font.i" can't be found; "DefaultFont" used instead.")
  3117.         Font.i = DefaultFont
  3118.       end
  3119.     end
  3120.     GETMASTERPAGES MPage; PageName = MPage.0
  3121.     GETMEASUREMENTS COORDINATE stemc RELATIVE rel TEXT tex FROM fro
  3122.     UserPrefs = 'SETMEASUREMENTS COORDINATE 'stemc.horizontal stemc.vertical' RELATIVE 'rel' TEXT 'tex' FROM 'fro
  3123.     SETMEASUREMENTS COORDINATE Inches Sameas RELATIVE Sameas TEXT Points FROM Page
  3124.     GETMARGINGUIDES temp
  3125.     Margin.Left   = temp.inside
  3126.     Margin.Right  = temp.outside
  3127.     Margin.Top    = temp.top
  3128.     Margin.Bottom = temp.bottom
  3129.  
  3130.     GETDIMENSIONS layout MASTERPAGE "'"PageName"'"
  3131.     if layout.orientation == 'LANDSCAPE' then do
  3132.       TextArea   = WTextArea
  3133.       FullWidth  = layout.height
  3134.       FullHeight = layout.width
  3135.     end
  3136.     else do
  3137.       TextArea   = TTextArea
  3138.       FullWidth  = layout.width
  3139.       FullHeight = layout.height
  3140.     end
  3141.   end
  3142.   PrintWidth       = FullWidth - Margin.Left - Margin.Right
  3143.   PrintHeight      = FullHeight - Margin.Top - Margin.Bottom
  3144.  
  3145.   if App == 'FW' then do
  3146.     GETOBJECTCOORDS TempDateID; Parse Var result . . . . Height.4pt
  3147.   end
  3148.   else if App == 'PGS' then Height.4pt = GetHeight(4pt)
  3149.   if ((PrintHeight - Height.4pt - (TextArea * PrintHeight))/5 * 8) >= 4 then
  3150.       PrintHeight = PrintHeight - Height.4pt
  3151.  
  3152.   CalendarBorder   = CalendarBorder * PrintWidth
  3153.   CalendarShadow   = CalendarShadow * PrintWidth
  3154.   PrintWidth       = PrintWidth - 2 * CalendarBorder - CalendarShadow
  3155.   PrintHeight      = PrintHeight - 2 * CalendarBorder - CalendarShadow
  3156.   Margin.Left      = Margin.Left + CalendarBorder
  3157.  
  3158.   BoxWidth         = PrintWidth/(WeekdayCount + 1)
  3159.   CalRight         = Margin.Left + BoxWidth * (WeekdayCount + 1)
  3160.   TextArea         = TextArea * PrintHeight
  3161.   CalTop           = TextArea + Margin.Top + CalendarBorder
  3162.   BoxHeight        = (PrintHeight - TextArea)/5
  3163.   CRadius          = CornerRadius * min(BoxHeight, BoxWidth)
  3164.   CurveOffset      = DateOffset * BoxWidth + CRadius * .25
  3165.   DateOffset       = DateOffset * BoxWidth
  3166.   FSize.Date       = BoxHeight/HighlightRows * 72 * StretchDateH
  3167.   Width.Date       = Width.Date * StretchDateW / StretchDateH
  3168.   FSize.Highlight  = BoxHeight/AddEventRows * 72
  3169.   if App == 'FW' then FSize.Highlight = max(trunc(FSize.Highlight), 4)
  3170.   if App == 'FW' then FSize.Date = max(trunc(FSize.Date), 4)
  3171.   Height.Highlight = GetHeight(Highlight) * Leading/100
  3172.   Height.Date      = GetHeight(Date) * Leading/100
  3173.  
  3174.   FontInfo = compress(Font.Highlight''FSize.Highlight, '. /:')
  3175.   FontKnown.FontInfo = Highlight
  3176.  
  3177.   RowsThatFit      = trunc(BoxHeight / Height.Highlight + 0.05)
  3178.   Width.WidthOfDate1 = GetFontWidth(Date, '1')
  3179.   Width.WidthOfDate8 = GetFontWidth(Date, '8')
  3180.   VariablesSet = 1
  3181.  
  3182.   interpret 'GfxCmd = GfxCmd.'GfxApp
  3183.   interpret 'GfxTemplate = GfxTemplate.'GfxApp
  3184. return
  3185. /**/
  3186.  
  3187. /***//*** VarList () Subroutine ***/
  3188. VarList:
  3189.   AddEventRows             = 9
  3190.   AdjustDST                = 1
  3191.   AltColor.Date            = Black$
  3192.   AltColor.Extended        = Black$
  3193.   AltColor.Highlight       = Black$
  3194.   AltColor.HighlightH      = Black$
  3195.   AltColor.History         = Black$
  3196.   AltColor.Julian          = Black$
  3197.   AltColor.Random          = Black$
  3198.   AltColor.Sunrise         = Black$
  3199.   AltColor.Sunset          = Black$
  3200.   AltColor.WeekNumber      = Black$
  3201.   Background.AddEvent      = White$
  3202.   Background.CalShadow     = Black$
  3203.   Background.Highlight     = '<'Clear$'>'
  3204.   Background.HighlightH    = '<'Clear$'>'
  3205.   Background.MiniCal       = White$
  3206.   Background.MiniCalShadow = Black$
  3207.   Background.NoteBox       = '<'Clear$'>'
  3208.   Background.Standard      = '<'Clear$'>'
  3209.   Background.Weekend       = '<'Clear$'>'
  3210.   BelzierFactor            = .55
  3211.   Bold.MiniCal             = DefaultBold
  3212.   Bold.FYMiniCal           = DefaultBold
  3213.   CalendarBorder           = 0
  3214.   CalendarShadow           = 0
  3215.   CenterHistory            = 1
  3216.   CenterMiniDates          = 1
  3217.   CenterRandom             = 1
  3218.   Color.Sunday             = Black$
  3219.   Color.Monday             = Black$
  3220.   Color.Tuesday            = Black$
  3221.   Color.Wednesday          = Black$
  3222.   Color.Thursday           = Black$
  3223.   Color.Friday             = Black$
  3224.   Color.Saturday           = Black$
  3225.   Color.AddEvent           = Black$
  3226.   Color.Date               = Black$
  3227.   Color.Extended           = Black$
  3228.   Color.Header             = Black$
  3229.   Color.Highlight          = Black$
  3230.   Color.HighlightH         = Black$
  3231.   Color.History            = Black$
  3232.   Color.Julian             = Black$
  3233.   Color.MiniCal            = Black$
  3234.   Color.Moon               = Black$
  3235.   Color.NoteBox            = Black$
  3236.   Color.Random             = Black$
  3237.   Color.SubHeader          = Black$
  3238.   Color.Sunrise            = Black$
  3239.   Color.Sunset             = Black$
  3240.   Color.Weekday            = Black$
  3241.   Color.WeekNumber         = Black$
  3242.   CornerRadius             = 0
  3243.   DateOffset               = 2
  3244.   DoDailyColors            = 0
  3245.   DoDateBox                = 0
  3246.   DoExtended               = 1
  3247.   DoHide                   = 0
  3248.   DoHighlights             = 0
  3249.   DoHistory                = ''
  3250.   DoImages                 = 0
  3251.   DoJulian                 = ''
  3252.   DoJulianLeft             = ''
  3253.   DoMatchColors            = 0
  3254.   DoMiniCals               = 1
  3255.   DoNoteBox                = 0
  3256.   DoPhases                 = ''
  3257.   DoRandom                 = ''
  3258.   DoSunRise                = ''
  3259.   DoSunSet                 = ''
  3260.   DoTopExtraWk             = 0
  3261.   DoWeekNumber             = ''
  3262.   FinalView                = 75
  3263.   Font.Date                = DefaultFont
  3264.   Font.Extras              = DefaultFont
  3265.   Font.Header              = DefaultFont
  3266.   Font.Highlight           = DefaultFont
  3267.   Font.MiniCal             = DefaultFont
  3268.   Font.FYMiniCal           = DefaultFont
  3269.   Font.Weekday             = DefaultFont
  3270.   Font.SubHeader           = DefaultFont
  3271.   ForceBGUI                = 0
  3272.   GenMVars                 = 'Month.Month EnteredYear'
  3273.   GenYVars                 = 'EnteredYear'
  3274.   GfxApp                   = 'FWCalendar'
  3275.   GfxAppPath               = ''
  3276.   HeaderLoc                = 9
  3277.   HeaderSize               = 50
  3278.   Header$                  = '%s %s'
  3279.   HeaderVars               = 'Month.Month Year'
  3280.   HelpTime                 = 4
  3281.   HighlightRows            = 9
  3282.   HostScreen               = ''
  3283.   LaunchM                  = ''
  3284.   LaunchY                  = ''
  3285.   Leading                  = 100
  3286.   Line.AddEvent            = Black$
  3287.   Line.CalBorder           = Black$
  3288.   Line.Extended            = Black$
  3289.   Line.Grid                = Black$
  3290.   Line.MiniCal             = Black$
  3291.   Line.NoteBox             = Black$
  3292.   MagnifyExtras            = 100
  3293.   Margin.Bottom            = 0
  3294.   Margin.Left              = 0
  3295.   Margin.Right             = 0
  3296.   Margin.Top               = 0
  3297.   MinHistoryWidth          = 70
  3298.   MinRandomWidth           = 70
  3299.   MinWidth                 = 80
  3300.   MaxImgHeight             = 75
  3301.   MaxImgWidth              = 75
  3302.   MiniCalHeight            = 60
  3303.   MiniCalSpacing           = 0.5
  3304.   MiniCalWidth             = 200
  3305.   MoonRadius               = 10
  3306.   Orientation              = 'Wide'
  3307.   PrefsName                = 'Default'
  3308.   ShadowType               = 'P'
  3309.   ShiftLMini               = 0
  3310.   ShiftRMini               = 0
  3311.   StartWeek                = 0
  3312.   StretchDateH             = 100
  3313.   StretchDateW             = 100
  3314.   SubHeaderLoc             = 0
  3315.   SubHeaderSize            = 0
  3316.   SubHeader$               = ''
  3317.   SubHeaderVars            = ''
  3318.   SunCalcPath              = ''
  3319.   Text.Julian              = ''
  3320.   Text.Sunrise             = ''
  3321.   Text.Sunset              = ''
  3322.   Text.WeekNumber          = ''
  3323.   TextAdj                  = 77
  3324.   TTextArea                = 15
  3325.   WeekdaySize              = 50
  3326.   WTextArea                = 20
  3327. return
  3328. /**/
  3329.  
  3330.